how to get the state of RadToggleButton in ViewModel?

1 Answer 260 Views
Buttons
onduty
Top achievements
Rank 1
onduty asked on 27 Aug 2021, 08:23 AM

The RadToggleButton is in example.xaml, how to get the statue of it(ischeck or not) in ViewModel.cs ?

And change the statue of Button in ViewModel.cs?

Thanks~

1 Answer, 1 is accepted

Sort by
0
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
answered on 27 Aug 2021, 09:25 AM | edited on 27 Aug 2021, 09:26 AM

Hello.

 

I've attached a simple example.

It displays the status when the toggle button is pressed.

 

You can control the toggle button via IsChecked.


<telerik:RadToggleButton Content="Click" Height="80" Width="120"
                                 IsChecked="{Binding IsChecked}"
                                 Command="{Binding OnClickCommand}"/>
private bool isChecked = false;
public bool IsChecked
{
    get => isChecked;
    set
    {
        isChecked = value;
        OnPropertyChanged("IsChecked");
    }
}

Is this what you want?

onduty
Top achievements
Rank 1
commented on 28 Aug 2021, 04:04 PM

Yes, thanks Psyduck ~
Tags
Buttons
Asked by
onduty
Top achievements
Rank 1
Answers by
Psyduck
Top achievements
Rank 5
Bronze
Bronze
Bronze
Share this question
or