I'm following this answer on how to databind enums (ints in my case) to RadioButtons, but if I've got several TabItems each with 10x10 grids of RadioButtons, is there any way to get rid of some of that boilerplate? As is, each RadioButton has to have all this info with it:
<RadioButton
IsChecked="{Binding
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}},
Path=FavoriteColor,
Converter={StaticResource IntToBoolConverter},
Mode=TwoWay,
ConverterParameter=5}"
Content="Red" Grid.Column="4" Grid.Row="6" />
Preferably I'd like to be able to set the RelativeSource, the Converter, and the Mode once in the TabControl, the Path once in each TabItem, and only have the ConverterParameter set per RadioButton. Is this possible in XAML? If not, would doing it in codebehind make more sense?
Here would be an improvement on my answer on a related question, utilizing the single selection mode of
ListBoxes
:The style to make the
ListBox
itself disappear: