I have a WPF user contol, in which I have a StackPanel. To this panel I’m adding programatically a label this way (Container is the name of StackPanel):
public void Insert(string Value)
{
Label l = new Label();
l.Content = Value;
Container.Children.Add(l);
}
Now I want to provide some public event SelectedIndexChange, when user clicks on label. Now I have a problem how determine which label was clicked. Can someone help?
If in
Insertyou add the line:then the first argument of ClickHandler will be the control that raised the Click event.
e.g. If your handler is:
then
senderwill be the label that was clicked.You could alternatively look at
e.OriginalSource.