Just curious as to how to modify a dynamic variable after creation.
I figure, I could just store them into some sort of list.
But I do assign them a name and event and wanted to know when the event is triggered would it be possible to modify the item with its name ?(object sender)
开发者_如何学JAVAEdit Clarification:
On run time create new items and associate them with events.
Image img = new Image();
img.name = "Image" + someIntValue;
img.MouseDown += new MouseButtonEventHandler(selectedImageClick);
someGrid.Children.add(img);
void selectedImageClick(object sender, MouseButtonEventArgs e)
{
//Modify that image e.g: border
}
In order to modify the sender, you'll have to cast it. Your event handler would then look something like this:
void selectedImageClick(object sender, MouseButtonEventArgs e)
{
Image img = sender as Image;
if (img != null) // In case someone calls this event handler with something other than an Image
{
//Modify that image e.g: border
}
}
精彩评论