Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In debugging a fired event, I viewed the object sender in the Watch window
C#
void SelectAssetGraphic(object sender, SelectionChangedEventArgs e) {  }

Under the sender, I could see Sender's items, e.g. one of them is GraphicsLayer.ID (its value='phones'). In the Immediate Winder, when I entered
sender.GraphicsLayer.ID
The returning message liked that:
'object' does not contain a definition for 'GraphicsLayer' and no extension method 'GraphicsLayer' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?
What's the approach to get the value from sender? Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 27-Jan-15 14:36pm    
This post lacks context. You never mentioned any code containing GraphicsLayer and the like.
—SA

1 solution

object sender needs to be cast to the object that produced the event e.g
C#
Button b = (Button)sender;


That is if you know what object it is, otherwise do something like this:

C#
if(sender is Button)
{
Button b = (Button)sender;
}
 
Share this answer
 
Comments
s yu 28-Jan-15 15:15pm    
Bacchus Beale: Thanks for your response. Actually, I tried the approach you posted but it does not work. The sender's type is ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid. In the Locals window, under the sender, there is an item: GraphicsLayer. However, no matter how to try, I can't retrieve sender.GraphicsLayer.ID value. Thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900