观ConfigRole有2列,名称和的IsEnabled(复选框)与按钮编辑的每一行,复选框DataGrid中MVVM WPF
ConfigRole:
**如果复选框为TRUE在ConfigRole视图中的一行,当我点击编辑按钮时,我得到具有2列Name_Button和IsEnabled(CheckBox)的新的View Button_Lists ...并且我修改了每个IsEnabled的TRUe或FALSe。
**我OBJECTIF是:当的IsEnabled ConfigRole是假的,我想所有的IsEnabled Button_Lists默认为FALSE,
ButtonList:
这是Button_Lists我try代码型号:
// get all of ButtonsList
public ObservableCollection<ButtonRoleMapClass> ButtonList
{
get { return _buttonList; }
set
{
_buttonList = value;
OnPropertyChanged("ButtonList");
}
}
//viewRoleButton: the Name of selected row in ConfigRole
public ButtonListViewModel(ViewRoleMapClass viewRoleButton)
{
//If IsEnabled for row in ConfigRole is FALSE
if (viewRoleButton.IsEnabled==false)
{
ObservableCollection<ButtonRoleMapClass> butsList = new ObservableCollection<ButtonRoleMapClass>();
foreach (ButtonRoleMapClass button in _buttonList)
{
button.IsEnabled = false;
butsList.Add(button);
}
_buttonList = butsList;
}
我想获得查看Button_Lists默认DataGrid中所有的复选框为FALSE,
我怎样才能解决这个问题?
有什么错误?你可以给视图的代码吗? – Etienne
使用ButtonList = butsList直接。那么你的PropertyChanged应该工作。 –
不,_buttonList是值;所以_buttonList = butsList;是正确的 – devtunis