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

Problem with IsChecked databinding?

1 Answer 209 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.
Martin
Top achievements
Rank 1
Martin asked on 22 May 2012, 08:41 AM

Hi, I got problem with binding IsChecked property to my bool property in ViewModel, it looks like changes in viewModel are not propagated to ToggleSwitch, or am I missing something?

in MainPage.xaml

<ToggleSwitch:ToggleSwitchButton IsChecked="{Binding Toggle, Mode=TwoWay}"/>
<Button Content="Button" Click="Button_Click"/>
<TextBlock TextWrapping="Wrap" Text="{Binding Toggle}"/>
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
    MainViewModel model = ServiceLocator.Current.GetInstance<MainViewModel>();
    model.Toggle = !model.Toggle;
}
in ViewModel:   
public bool Toggle
{
    get { return toggle; }
    set
    {
        if (toggle == value) return;
        toggle = value;
        RaisePropertyChanged(() => Toggle);
    }
}
private bool toggle;

the text in textbox is updating, but Toggle is still Off - any hint? 

Note: we use currently intermediate build 2012.2.518.2040

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 23 May 2012, 08:30 AM
Hello Martin,

Thank you for your interest in RadToggleSwitch.

The control that you need is called RadToggleSwitch and it is part of the Telerik.Windows.Controls namespace. This is described in our online documentation. You have added only a ToggleSwitchButton which is only one of the visual parts of the control and it does not include all the logic that is necessary to make it work. If you want to see only the ToggleSwitchButton, without the text that comes with it in the default look of the control, you can set the Content property to {x: Null}.

I hope this information helps. If you need additional assistance, we will be happy to help.

Greetings,
Todor
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ToggleSwitch
Asked by
Martin
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or