How to Bind a nullable bool in VM to RadRadioButton

I am struggling with how I go about this? In my VM I have a nullable bool property that I want to bind to a Yes/No(true/false) RadRadioButton. Can someone point me in the right direction?

VM

public bool? IsSDS { get; set; }

View

<telerik:Label Content="Self Directed Support" />
<StackPanel Orientation="Horizontal">
     <telerik:RadRadioButton x:Name="SelfDirectedSupportYes" Content="Yes" />
     <telerik:RadRadioButton x:Name="SelfDirectedSupportNo" Content="No" />
</StackPanel>

EDIT

I thought this was working but I was mistaken. Only Yes is binding. Below is what's on my View, CreateAuthView:

<StackPanel Orientation="Horizontal" Margin="3" Grid.Column="1" Grid.Row="2">
   <telerik:RadRadioButton x:Name="Authorization_SelfDirectedSupportYes" GroupName="SDS" Content="Yes" />
    <telerik:RadRadioButton x:Name="Authorization_SelfDirectedSupportNo" GroupName="SDS" Content="No" />
</StackPanel>

and here is the corresponding portion on my ViewModel, CreateAuthViewModel:

public Authorization Authorization
{
    get
    {
       return this.authorization;
    }
    set
    {
       if (authorization != value)
       {
          this.authorization = value;
          NotifyOfPropertyChange(() => Authorization);                    
       }
    }
}

And finally the Property on my Model, Authorization:

public bool? SelfDirectedSupportYes
{
   get
   {
      return this.selfDirectedIndicator;
   }
   set
   {
      this.selfDirectedIndicator = value;
      this.OnPropertyChanged();
   }
}

Answers


IsChecked is also of type Nullable<bool>, so you can bind it directly the "yes" radio button. And if you set the same GroupName for both radio buttons, you don't need to bind the "no" radio button at all (since checking "no" will uncheck "yes")

<telerik:Label Content="Self Directed Support" />
<StackPanel Orientation="Horizontal">
     <telerik:RadRadioButton x:Name="SelfDirectedSupportYes" GroupName="SelfDirectedSupportOption" Content="Yes" IsChecked="{Binding IsSDS}" />
     <telerik:RadRadioButton x:Name="SelfDirectedSupportNo" GroupName="SelfDirectedSupportOption" Content="No" />
</StackPanel>

Need Your Help

Working with Youtube Google API & jQuery

jquery json youtube-api

I'm iterating through each li that is generated by the db which produces a youtube link to the video I want to link to So essentially I have this:

Python: How can I gather and parse csv data from a webpage?

python csv cgi urllib

I have a webpage that prints out csv data using a cgi script. I want to parse the data using Python. So far I know that I can use urllib to request the url and obtain the html into one giant byte s...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.