Reputation: 41
I have a grid filled with buttons. Is there any way to give each button some kind of numeric value? (some kind of a tag that I could later refer to when comparing the buttons).
I tried using the Tag property but it seems not to accept numbers (unless precedent by letters).
Thanks for the help.
Upvotes: 0
Views: 87
Reputation: 3073
If you are binding this to a view model, to do something on the click of a button, then you could do it like this:
<Button Name="Button1" Content="1" Command="{Binding NumberButton}" CommandParameter="1"/>
<Button Name="Button2" Content="2" Command="{Binding NumberButton}" CommandParameter="2"/>
....
Then in the command you've bound to in your viewmodel, you can do something appropriate with the command parameter which has been passed in:
NumberButton = new DelegateCommand<string>(number =>
{
/*... */
}, i => true);
Upvotes: 1