Note that there are some explanatory texts on larger screens.

plurals
  1. PODatabind radiobutton group to property
    text
    copied!<p>I have a radiobutton group:</p> <pre><code>&lt;TextBlock Height="24" Text="Update Interval (min):"/&gt; &lt;RadioButton x:Name="radioButtonTimerNone" IsChecked="{Binding UpdateInterval, Converter={StaticResource updateIntervalToCheckedConverter}, Mode=TwoWay}"} Content="None" /&gt; &lt;RadioButton x:Name="radioButtonTimerOne" IsChecked="{Binding UpdateInterval, Converter={StaticResource updateIntervalToCheckedConverter}, Mode=TwoWay}" Content="1" /&gt; &lt;RadioButton x:Name="radioButtonTimerFive" IsChecked="{Binding UpdateInterval, Converter={StaticResource updateIntervalToCheckedConverter}, Mode=TwoWay}" Content="5" /&gt; </code></pre> <p>And a property:</p> <pre><code> public int UpdateInterval { get { return _updateInterval; } set { _updateInterval = value; onPropertyChanged("UpdateInterval"); } } </code></pre> <p>How do I bind the radiobuttons to the property, so radioButtonTimerNone is checked when UpdateInterval is 0, radioButtonTimerOne is checked when UpdateInterval is 1, etc.<br> I have tried to create a converter, but it doesn't identify which rb is being set: </p> <pre><code>[ValueConversion(typeof(RadioButton), typeof(bool))] class UpdateIntervalToCheckedConverter : System.Windows.Data.IValueConverter public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) </code></pre> <p>I expected 'value' to be a radiobutton, but it appears to be the value of UpdateInterval.</p> <p>Thanks for any hints... </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload