【发布时间】:2022-07-09 03:57:25
【问题描述】:
我有一个 DataGrid 并将其项目源绑定到下面的类列表。如何将数据网格行 IsSelected 属性绑定到类 IsChecked 属性?
public class DeckInt : INotifyPropertyChanged
{
public int id { get; set; }
public string name { get; set; }
public bool isChecked { get; set; }
public int Id { get { return id; } set { id = value; OnPropertyChanged(nameof(Id)); } }
/// <summary>
/// Group name of the weight item
/// </summary>
public string Name { get { return name; } set { name = value; OnPropertyChanged(nameof(Name)); } }
public bool IsChecked { get { return isChecked; } set { isChecked = value; OnPropertyChanged(nameof(IsChecked)); } }
public event PropertyChangedEventHandler PropertyChanged;
//When propert changes, notify
protected virtual void OnPropertyChanged(string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
【问题讨论】:
标签: c# wpf data-binding binding datagrid