Wpf 从视图模型中选择datagrid行中的所有复选框
我在WPF应用程序中使用Caliburn Micro作为MVVM框架。我对如何在datagrid控件中选中所有复选框没有什么问题。每个datagrid行都有复选框 我绑定列表的datagrid属性类型 型号:Wpf 从视图模型中选择datagrid行中的所有复选框,wpf,select,mvvm,datagrid,checkbox,Wpf,Select,Mvvm,Datagrid,Checkbox,我在WPF应用程序中使用Caliburn Micro作为MVVM框架。我对如何在datagrid控件中选中所有复选框没有什么问题。每个datagrid行都有复选框 我绑定列表的datagrid属性类型 型号: public class Bill : INotifyPropertyChanged { public string CellPhoneNo { get { return _cellPhoneNo; } set {
public class Bill : INotifyPropertyChanged
{
public string CellPhoneNo
{
get { return _cellPhoneNo; }
set
{
_cellPhoneNo = value;
NotifyPropertyChanged("CellPhoneNo");
}
}
public bool IsSelected
{
get { return _isSelected; }
set
{
_isSelected = value;
NotifyPropertyChanged("IsSelected");
}
}
视图模型:
public IList<Bill> TmobileBill
{
get
{
return _tmobileBill;
}
set
{
_tmobileBill = value;
NotifyOfPropertyChange(()=>TmobileBill);
}
}
视图中的复选框未选中。问题的根源是什么
多谢各位
IList
更改为ObservableCollection
<TextBlock Text="{Binding}"></TextBlock>
您使用的是哪种类型的控件?(数据网格)
<Controls:DataGrid.RowHeaderTemplate>
<DataTemplate>
<Grid>
<CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Controls:DataGridRow}}}"/>
</Grid>
</DataTemplate>
</Controls:DataGrid.RowHeaderTemplate>
foreach (var row in TmobileBill)
{
row.IsSelected = true;
}
<TextBlock Text="{Binding}"></TextBlock>