w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to get all column header checkbox selected in datagrid when I click on a checkbox which is not a part of datagrid in wpf?

By Element Binding, this will solve the issue..

<DataTemplate>                    
                <StackPanel Name="stkPanel" MinHeight="80"
MinWidth="500" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <DataGrid Grid.Column="1" 
                              AutoGenerateColumns="True" 
                              MinHeight="75" 
                              HorizontalAlignment="Center" 
                              Name="dataGrid1" 
                              VerticalAlignment="Stretch" 
                              MinWidth="470" 
                              MaxWidth="900" 
                              ItemsSource="{Binding}" 
                              IsReadOnly="True" Background="#E6BAB7B7">
                        <DataGrid.ColumnHeaderStyle>
                            <Style TargetType="DataGridColumnHeader">
                                <Setter Property="ContentTemplate">
                                    <Setter.Value>
                                        <DataTemplate>
                                            <CheckBox Name="colCheckBox"
IsChecked="{Binding IsChecked, ElementName=IsDone, Mode=OneWay}"
Content="{Binding}"/>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </DataGrid.ColumnHeaderStyle>
                    </DataGrid>
                    <CheckBox  Grid.Column="0" Height="35" Width="25"
x:Name="IsDone" HorizontalAlignment="Right" VerticalAlignment="Center"
Checked="IsDone_Checked" />
                    </Grid>                        
            </StackPanel>                   
        </DataTemplate>




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.