wpf RadioButton绑定到不同属性

wpf RadioButton绑定到不同属性,wpf,boolean,Wpf,Boolean,我有以下SQL表结构 DeleteOwn作为位0或1 DeleteAll作为位0或1 节点节点作为位0或1 在XAML中,我有以下内容 下面是currentItem的关联方式 Private Sub ChangeSelected(sender As Object, e As RoutedPropertyChangedEventArgs(Of Object)) Dim MyTreeView As TreeView = DirectCast(sender, TreeView)

我有以下SQL表结构

  • DeleteOwn作为位0或1
  • DeleteAll作为位0或1
  • 节点节点作为位0或1
  • 在XAML中,我有以下内容

    下面是currentItem的关联方式

    Private Sub ChangeSelected(sender As Object, e As RoutedPropertyChangedEventArgs(Of Object))
               Dim MyTreeView As TreeView = DirectCast(sender, TreeView)
               CurrentItem = MyTreeView.SelectedItem
               NotifyProperty("CurrentItem")
    End Sub
    
    当数据加载到窗口中时,值显示正确,但在通过单击单选按钮更改值后,绑定将丢失,并向单选按钮显示不正确的值。
    我怎样才能让它工作

    我不知道这是否对其他人有帮助,但我可以通过做两件事来修复它

    • 例如,在每个单选按钮中,我必须声明3个不同的组名(这对我来说是错误的,但为了使其工作,我没有其他方法)

                          <RadioButton GroupName="a"/>
                          <RadioButton GroupName="b"/>
                          <RadioButton GroupName="c"/>
      
      
      
    • 每次其中一个单选按钮将状态更改为True时,其他单选按钮都应设置为false,我原以为这种行为是开箱即用的

      (单选按钮中的绑定不起作用时)


    但是我必须自己实现它,因为绑定不能正常工作,所以在代码隐藏中,当我的一个属性更改为True时,我会将逻辑设置为False,其他属性设置为False
    Private Sub ChangeSelected(sender As Object, e As RoutedPropertyChangedEventArgs(Of Object))
               Dim MyTreeView As TreeView = DirectCast(sender, TreeView)
               CurrentItem = MyTreeView.SelectedItem
               NotifyProperty("CurrentItem")
    End Sub
    
                        <RadioButton GroupName="a"/>
                        <RadioButton GroupName="b"/>
                        <RadioButton GroupName="c"/>