I\'ve got some RadioButtons in my XAML...
In order for commands to work you need to set up bindings in either your xaml or code behind. These command bindings must reference public static fields that have been previously declared.
Then in your buttons Command attribute you will then need to also reference these same commands.
One
Two
Three
public partial class Window1 : Window
{
public static readonly RoutedCommand CommandOne = new RoutedCommand();
public static readonly RoutedCommand CommandTwo = new RoutedCommand();
public static readonly RoutedCommand CommandThree = new RoutedCommand();
public Window1()
{
InitializeComponent();
}
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
if (e.Command == CommandOne)
{
MessageBox.Show("CommandOne");
}
else if (e.Command == CommandTwo)
{
MessageBox.Show("CommandTwo");
}
else if (e.Command == CommandThree)
{
MessageBox.Show("CommandThree");
}
}
}