Hi,

I have a WPF datagrid with datagrid check box column as first column and the header of the checkbox column is also a check box..

I am using the follwoing code to achieve this..

<TK:DataGridCheckBoxColumn Width="30" Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type TK:DataGridRow}}}">
                                        <TK:DataGridCheckBoxColumn.HeaderStyle>
                                            <Style TargetType="{x:Type TKPrimitives:DataGridColumnHeader}">
                                                <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}"/>
                                                <Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" />
                                                <Setter Property="BorderThickness" Value="0,1,0,1" />
                                                <Setter Property="Height" Value="20" />
                                                <Setter Property="FontSize" Value="11" />
                                                <Setter Property="FontFamily" Value="Verdana" />
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="{x:Type TKPrimitives:DataGridColumnHeader}">
                                                            <Grid>
                                                                <TK:DataGridHeaderBorder x:Name="headerBorder" 
                                                                                    Background="{TemplateBinding Background}"
							                                                        BorderBrush="{TemplateBinding BorderBrush}"
							                                                        BorderThickness="{TemplateBinding BorderThickness}">
                                                                    <Border BorderBrush="{StaticResource HeaderInnerBorderBrush}" 
									                                                BorderThickness="0,1,0,0">
                                                                        <CheckBox x:Name="HeaderCheckBox" HorizontalAlignment="Center"  Content="{Binding}"  Click="HeaderCheckBox_Click"/>
                                                                    </Border>
                                                                </TK:DataGridHeaderBorder>
                                                            </Grid>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </TK:DataGridCheckBoxColumn.HeaderStyle>
                                    </TK:DataGridCheckBoxColumn>

But my question is by using this code i have got the select all succesfully..but by selecting one check box in the list another check box is deselecting (With out holding Cntrl key)..But by using Cntrl key i am able to select multiple items in the list..

But I need code for only by clicking on check box with out using Cntrl key user can select the mutiple items in the datagrid..

Can any one help me..

Thanks in advance for help..

Regards,

Sravanthi Ch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.