This is a migrated thread and some comments may be shown as answers.

Help with Binding the toggleswitch

2 Answers 448 Views
ToggleSwitch
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GJ Kuz
Top achievements
Rank 1
GJ Kuz asked on 05 Nov 2012, 05:10 AM
Dear Telerik Team,

I am trying to bind the RadToggleSwitch control with my viewmodel and I can't seem to get it working. The field is defined as bool and is also nullable. Could you please help me?
<telerikPrimitives:RadToggleSwitch Header="Trade-in Deduction" Name="tsTradeinCredit" Grid.ColumnSpan="2" Margin="12,0,8,0" IsChecked="{Binding HasTradeInDeducation}" Checked="tsTradeinCredit_Checked" Unchecked="tsTradeinCredit_Unchecked" TabIndex="1" >
                                <telerikPrimitives:RadToggleSwitch.HeaderTemplate>
                                    <DataTemplate>
                                        <ContentControl Foreground="Black" Content="{Binding}" FontFamily="Segoe WP" FontSize="22.5"/>
                                    </DataTemplate>
                                </telerikPrimitives:RadToggleSwitch.HeaderTemplate>
                                <telerikPrimitives:RadToggleSwitch.ContentTemplate>
                                    <DataTemplate>
                                        <ContentControl Content="{Binding}"  Foreground="Black" FontFamily="Segoe WP" FontSize="22.5" />
                                    </DataTemplate>
                                </telerikPrimitives:RadToggleSwitch.ContentTemplate>
                            </telerikPrimitives:RadToggleSwitch>

2 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 06 Nov 2012, 03:43 PM
Hi Gilles,

Thank you for contacting us.

I used your code and had no issues binding the IsChecked property to a nullable boolean property of a ViewModel. Could you please have a look at the attached project and let me know if I'm missing something?

Kind regards,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
GJ Kuz
Top achievements
Rank 1
answered on 14 Nov 2012, 06:43 PM
Hi Todor,

The sample works great!!! It was a stupid mistake on my side. Sorry for the trouble.

thanks,
Gilles
Tags
ToggleSwitch
Asked by
GJ Kuz
Top achievements
Rank 1
Answers by
Todor
Telerik team
GJ Kuz
Top achievements
Rank 1
Share this question
or