简体   繁体   English

检查Radiobutton已经改变了WPF

[英]Radiobutton checked has changed WPF

In my WPF application i have: 在我的WPF应用程序中,我有:

-> TextBox (textChanged) - > TextBox(textChanged)

-> 2 radio buttons - > 2个单选按钮

-> ListView with content. - >包含内容的ListView。 "Author","Title". “作者”,“标题”。

I need to allow searching from Listview. 我需要允许从Listview中搜索。

My question is: How i should check if radiobutton check is changed? 我的问题是:我应该如何检查radiobutton检查是否改变了?

As mentioned in the comments MVVM is prefered for WPF then you would bind to the IsChecked Property. 正如评论中所提到的,MVVM首选WPF,然后绑定到IsChecked属性。

private bool _RadioButtonChecked;
public bool RadioButtonChecked
{
    get => _RadioButtonChecked;
    set
    {
        _RadioButtonChecked = value;
        //Refresh filter here
    }
}

Xaml binding: Xaml绑定:

<RadioButton Content="RadioButton" IsChecked="{Binding RadioButtonChecked}"/>

Aside from that there is are Checked and UnChecked events that you can use. 除此之外,还有可以使用的CheckedUnChecked事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM