Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:02:30+00:00 2026-06-02T15:02:30+00:00

I have created a data table which contains 4 columns, 3 are strings and

  • 0

I have created a data table which contains 4 columns, 3 are strings and another one is Boolean type.
i mapped the datatable(xmldatadocument) to the datagridview in wpf.
so the resulting looks text column and checkbox column in data grid.
And i added a checkbox header template to the chekbox column header.
I am able to perform uncheck all checkboxes in column when i\the header checkbox is unchecked.
I am also able to perform check all checkboxes in column when the header chekcbox is checked.but i am bit troubled in if one of checkbox in that column is unchecked i need to uncheck the header checkbox also..
Kindly help me to resolve this..
i’ve added the screenshot, XAML and Code below.

Datagridview

PS: using WPF datagrid.

<dg:DataGrid.Columns>
                <dg:DataGridCheckBoxColumn Binding="{Binding Check}" Width="50" >
                    <dg:DataGridCheckBoxColumn.HeaderTemplate>
                        <DataTemplate x:Name="dtAllChkBx">
                            <CheckBox Name="cbxAll" Content="{x:Static properties:Resources.lblAll}" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked"></CheckBox>
                        </DataTemplate>
                    </dg:DataGridCheckBoxColumn.HeaderTemplate>


public static ObservableCollection<Lst> list = new ObservableCollection<Lst>();
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
    for (int i = 0; i < list.Count; i++)
    {
        list[i].Check = true;
    }
}

private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
    for (int i = 0; i < list.Count; i++)
    {
        list[i].Check = false;
    }
}

public class Lst : ObservableCollection<Lst>
{
    public bool Check { get; set; }
}  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:02:32+00:00Added an answer on June 2, 2026 at 3:02 pm

    Here is the control template for the header

    <Style x:Key="checkBoxHeaderStyle"
                               TargetType="{x:Type w:DataGridColumnHeader}">
                                                        <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type w:DataGridColumnHeader}">
                                        <CheckBox 
                                                  IsChecked="{Binding  Path = IsSelectAllChecked , Mode = TwoWay}"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
    

    Here is the template column applying the style

    <w:DataGridTemplateColumn MinWidth="50"
                                                  HeaderStyle="{DynamicResource checkBoxHeaderStyle}"
                                                  CanUserResize="False">
                            <w:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox Name="selectAllCheckBox"
                                                                      HorizontalAlignment="Center"                                              Margin="1,0,0,0"                                                                                            VerticalAlignment="Center"
                                              IsChecked="{Binding Path = IsSelected, Mode=TwoWay}" />
                                </DataTemplate>
                            </w:DataGridTemplateColumn.CellTemplate>
                        </w:DataGridTemplateColumn>
    

    The is selected property is

    public bool IsSelected
    {
        get { return selected; }
        set { selected = value;
        OnPropertyChanged("IsSelected");
        }
    }
    

    For the header check box

    public bool IsSelectAllChecked
            {
                get { return isSelectAllChecked; }
                set
                {
                    isSelectAllChecked = value;
                    base.OnPropertyChanged("IsSelectAllChecked");
    //Call the method which sets the IsSelected property to true of false, based on value
                    SetAllCheckBoxesState(value);
                }
    
        }
    

    I hope it helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an archive table which will store data for selecting only. Daily
I have a table which contains the following columns and I am trying to
i have a holiday table which contains the data are HOLIDAYDA DESCRIPTION --------- --------------------
I have a table with around 19 columns which contains reasonable large amount of
I have a GridView to which I bind a dataTable that I manually created.
I have created a JTable, the table contains 4 rows, and for a specific
I have a table 'TYPE' in this table i have 2 columns as 'SKEY'
I have two tables with hierarchyid fields, one of which is a staging table
My database name is AppDB.db and table name is Scrip which contains 3 columns
I have a grid view. Which contains some columns. Suppose, it has 10 columns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.