我想将WpfDatagrid行绑定到ViewModel中的布尔属性,以显示Row是否已更改。事实上,我有一个绑定到模型中的类的datagrid,并且在ViewModel中具有IsRowChanged属性,并且不要不知道如何将datagrid绑定到IsRowChanged?
<DataGrid ItemsSource="{Binding Produts}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTemplateColumn IsReadOnly="True" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsRowChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
If you use entity framework you can directly extend your entity partial class with this line
public bool IsRowChanged { get { return myEntity.EntityState == EntityState.Modified; } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.