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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…