I have the following style in my XAML:
<Style x:Key="NumberButton" TargetType="Button">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="Auto"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Label Content="{Binding}" FontSize="20" FontFamily="Consolas"/>
</DataTemplate>
</Setter.Value>
</Setter>
<EventSetter Event="Click" Handler="OnClicked"/>
</Style>
I create 10 <Button>
's and I apply this style to each of them. The Content=""
of each button is set to a number 0-9. I'd like to create an event handler for each of these buttons (through the style itself) that will pass in the value of the Content
property to the event handler in the code behind.
I'm still new to WPF so any help would be greatly appreciated. Thank you!