When using Datagridcheckboxcolumn binding a Boolean attribute, it is found that the checkbox cannot be checked and the checkbox in HeaderTemplate cannot get the Isselectall attribute to ViewModel ,
Finally, it is resolved by the following methods. Pay attention to the magnified part
<Datagridcheckboxcolumn x:name="Checkcolumn"Width=" +"Binding="{Binding path=isselected, Mode=twoway, updatesourcetrigger=propertychanged}"Canusersort="False"isreadonly="False"><DataGridCheckBoxColumn.ElementStyle> <style targettype="checkbox " /> </DataGridCheckBoxColumn.ElementStyle> <DataGridCheckBoxColumn.HeaderTemplate> <DataTemplate> <c Heckbox ischecked="{Binding path=datacontext.isselectall, Relativesource={relativesource mode=findancestor, AncestorType={x: Type DataGrid}}}"/> </DataTemplate> </DataGridCheckBoxColumn.HeaderTemplate> </DataGridCheckBoxColumn>
WPF Datagridcheckboxcolumn Issues