Untested wpf switches

I have two radio blocks.

One ( rb1) is bound to the my property ViewModel. If the property is true, it is rb1checked at application loading. If the false property [t20> is not checked (this is right).

But in the latter case, both radio objects are not marked, and I need the second radio camera to be (rb2)checked when the property is false. How can i do this?

+3
source share
1 answer

The problem you are facing is that the DataBinding is "lost." Let me quote Matt Thalman :

(, "" Foo ). , IsFoo IsBar - , IsChecked . Snoop, , IsChecked . , . IsChecked , .

RadioButton:

public class DataBoundRadioButton : RadioButton
{
     protected override void OnChecked(RoutedEventArgs e)
     {
          // Do nothing. This will prevent IsChecked from being manually set and overwriting the binding.
     }

     protected override void OnToggle()
     {
          // Do nothing. This will prevent IsChecked from being manually set and overwriting the binding.
     }
}

. .

0

Source: https://habr.com/ru/post/1782609/


All Articles