Hi Bruce,
We need to get an example of this in the documentation however it will work if you do something like this:
1) Change the command parameter to be a CheckableCommandParameter with a Tag of the color value:
<ribbon:RadioButton Label="Tan" ImageSourceSmall="/Images/ThemeTan16.png" Command="sample:ApplicationCommands.ThemeCustom">
<ribbon:RadioButton.CommandParameter>
<ribbon:CheckableCommandParameter Tag="Tan" />
</ribbon:RadioButton.CommandParameter>
</ribbon:RadioButton>
2) In the CanExecute for the command, based on which theme is selected and what value is in the Tag of the CheckableCommandParameter, you tell that particular item whether it is checked or not similar to the other examples.
3) Update the Execute for the command to look at the Tag of the parameter instead of the parameter itself (before it was a string instead of CheckableCommandParameter).
I just tried it out with a column of 3 radio buttons, using the custom theme selection as the test.
Here is the XAML code:
<ribbon:StackPanel SmallNoLabelVariantGroupSize="Large">
<ribbon:RadioButton Label="Tan" ImageSourceSmall="/Images/ThemeTan16.png" Command="sample:ApplicationCommands.ThemeCustom">
<ribbon:RadioButton.CommandParameter>
<ribbon:CheckableCommandParameter Tag="Tan" />
</ribbon:RadioButton.CommandParameter>
</ribbon:RadioButton>
<ribbon:RadioButton Label="Steel Blue" ImageSourceSmall="/Images/ThemeSteelBlue16.png" Command="sample:ApplicationCommands.ThemeCustom">
<ribbon:RadioButton.CommandParameter>
<ribbon:CheckableCommandParameter Tag="SteelBlue" />
</ribbon:RadioButton.CommandParameter>
</ribbon:RadioButton>
<ribbon:RadioButton Label="Green" ImageSourceSmall="/Images/ThemeGreen16.png" Command="sample:ApplicationCommands.ThemeCustom">
<ribbon:RadioButton.CommandParameter>
<ribbon:CheckableCommandParameter Tag="Green" />
</ribbon:RadioButton.CommandParameter>
</ribbon:RadioButton>
</ribbon:StackPanel>
Here is the CanExecuteMethod:
private void themeChangeCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) {
e.Handled = true;
e.CanExecute = true;
ICheckableCommandParameter parameter = e.Parameter as ICheckableCommandParameter;
if (parameter != null) {
parameter.Handled = true;
parameter.IsChecked = (RibbonColorScheme.Default.Key == (parameter.Tag + "ColorScheme"));
}
}
After adding that, the proper radio button is checked when the theme is active and everything is handled via the command model.
Hope that helps and of course, we're always open to any other suggestions.
UPDATE: We have enhanced the sample for the next maintenance release so that all the 9 theme buttons will use this sort of code to display which one of them is currently active. It will show the active theme's button as checked, which is the same concept as radio buttons. To do radio buttons you would just swap out the Button controls for RadioButtons instead.
[Modified at 05/21/2007 01:56 PM]