Simple solution:
<Button Tag="{Binding Code}" ...>
In your handler, cast the sender
object to Button
and access the Tag
property:
var myValue = ((Button)sender).Tag;
A more elegant solution would be to use the Command pattern of WPF: Create a Command for the functionality you want the button to perform, bind the Command to the Button’s Command
property and bind the CommandParameter
to your value.