Basically I’m dynamically adding items to a listbox. Inside of each listbox item I have also added a button control that will perform a specific action on the item from which the button was clicked.
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Title"/>
<Button Click="MyBtn_Click"/>
</StackPanel>
</DataTemplate>
Does anyone know how to determine which item the button was clicked from? I know each listbox item contains an index. I think if you could access the parent of the button you could then deterimine which button was clicked?
You could use the CommmandParameter of the button to hold a value –
Convention is to use the Command event instead of the click event for this type of thing.