I have the following xaml:
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Name}"></Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
In my code I have an event that gives me access to the button. How can I take the button object and get the object that it's Name is bound to?
Here is psudo code that I would like to work:
public void MyEvent(Object obj)
{
Button myButton = (Button) obj;
MyBoundClass myObject = GetBoundClassFromProperty(myButton.Name);
// Do something with myObject.
}