The SelectionChanged
event is not fired because the button is the control who captures the mouse click, not the ListBox
.
You can set your event handler to the button's click event instead.
<Button Height="90" Width="150" Click="myClickEventHandler"/>
Regardless, I recommend you to use MVVM, instead of Code-Behind event handler.
you could set a command which will fire when the button's click and send the command the button's content for example
<Button Name="myButton" Height="90" Width="150" Template="{StaticResource cbutton}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding DoSomething}" CommandParameter="{Binding ElementName=myButton, Path=Content}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
ViewModel
DoSomething = new DelegateCommand<object>(content=>
{
// Do whatever you want
});
If your not familar with MVVM, it will take some time to learn it, but it is definetly worth it :)