I have the following ComboBox element in XAML:
<ComboBox ItemsSource="{Binding CollectionControlValues}" SelectedItem="{Binding CollectionControlSelectedValue, UpdateSourceTrigger=PropertyChanged}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Value}" /> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
I would like to use RadioButtons in the same , for example:
pseudo code:
<RadioButtons ItemsSource="{Binding CollectionControlValues}" SelectedItem="{Binding CollectionControlSelectedValue, UpdateSourceTrigger=PropertyChanged}"> <RadioButtons .ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Value}" /> </DataTemplate> </RadioButtons .ItemTemplate> </RadioButtons >
However, the only WPF RadioButton implementations I can find are static , like this.
<StackPanel x:Name="rbHolder1" Style="{StaticResource rbStackPanelStyle}"> <RadioButton Style="{StaticResource rbStyle}">RadioButton 1</RadioButton> <RadioButton Style="{StaticResource rbStyle}">RadioButton 2</RadioButton> <RadioButton Style="{StaticResource rbStyle}">RadioButton 3</RadioButton> <RadioButton Style="{StaticResource rbStyle}">...</RadioButton> </StackPanel>
How to create a RadioButton control that is not static, as described above, but instead gets its data from its ItemsSource property, as in the ComboBox example above?
radio-button wpf xaml combobox
Edward tanguay
source share