HI All,
I am having a datagrid with SelectAll checkbox in column header of checkbox column.
XAML:
------------
<DataGrid.Columns><DataGridTemplateColumn Width="30">
<DataGridTemplateColumn.Header>
<CheckBox Name="CheckSelectAll"
IsChecked="{Binding DataContext.IsSelectAll,Mode=TwoWay, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}" >
</CheckBox>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=IsSelected,Mode=Twoway,UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
Then I am having Viwmodel With SelectAll Property:
public bool? IsSelectAll
{
get
{
return _isSelectAll;
}
set
{
_isSelectAll = value;
if (_isSelectAll.HasValue && _isSelectAll.Value)
{
SelectAll();
}
else
{
DeselectAll();
}
OnPropertyChanged("IsSelectAll");
}
}
-----
private void SelectAll(){
foreach (var InfoViewModel in Results)
{
InfoViewModel.IsSelectedInvoice = true;
}
}
private void DeselectAll()
{
foreach (var InfoViewModel in Results)
{
nfoViewModel.IsSelectedInvoice = false;
}
}
---------------------------
So Now my select all and deselect all functionality is working fine .But when i am checking any checkbox manually in grid I want to uncheck Selectall header checkbox.Please guide me to do that.
If i am trying to trigger in set section of IsSelectedInvoice property then it is circular for SelectAll and not working.