复选框PropertyChanged未触发

时间:2012-08-16 22:53:48

标签: c# wpf data-binding mvvm

我有一个MVVM应用程序正在进行并尝试绑定数据网格中的复选框,但Propertychanged事件不会触发。我已经在viewmodel和基类上实现了INotifypropertychanged,但仍然没有触发属性,并且复选框没有更新。我已经尝试了所有可能的东西,如seting updatesourcetrigger = explicit或propertychanged,但它只是不起作用。我可能做错了什么?我无法搞清楚。网格的datacontext设置为ListViewCollection,它绑定到ObservableCollection。

                                                                                                                                                                                                                                                              

                    <DataGridCheckBoxColumn Header="Tier1" Binding="{Binding Tier1Check,Mode=TwoWay}"></DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Header="Tier2" Binding="{Binding Tier2Check,Mode=TwoWay}"></DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Header="Tier3" Binding="{Binding Tier3Check,Mode=TwoWay}"></DataGridCheckBoxColumn>
                    <DataGridCheckBoxColumn Header="DoNotUse" Binding="{Binding DoNotUseCheck,Mode=TwoWay}"></DataGridCheckBoxColumn>

                    <!--<DataGridCheckBoxColumn Header="Tier1" Binding="{Binding IsChecked}"  />
                    <DataGridCheckBoxColumn Header="Tier2" Binding="{Binding IsChecked}" />
                    <DataGridCheckBoxColumn Header="Tier3" Binding="{Binding IsChecked}"/>-->
            </DataGrid.Columns>
        </DataGrid>

ViewModel ...我有四个复选框,代码专门用于使它们互斥。

 public bool? Tier1Check
      {
          get
          {
              return Tier1Check;
          }

          set
          {
              Tier1Check = value;
              Tier2Check = false;
              Tier3Check = false;
              DoNotUseCheck = false;
              RaisePropertyChanged("Tier2Check");
              RaisePropertyChanged("Tier3Check");
              RaisePropertyChanged("Tier1Check");
              RaisePropertyChanged("DoNotUseCheck");
          }
      }

0 个答案:

没有答案