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

  • SEARCH
  • Home
  • 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 8483191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:01:30+00:00 2026-06-10T20:01:30+00:00

I got a problem with datagrid and DataGridCheckBoxClumn. First of all im creating struct

  • 0

I got a problem with datagrid and DataGridCheckBoxClumn. First of all im creating struct for datagrid items:

public struct taxRateFromDatabase
{
    public int rate { get; set; }
    public string mark { get; set; }
    public CheckBox c { get; set; }
}

And after that in my class adding columns, bindings etc:

    StackPanel tSp = new StackPanel();
    DataGrid taxRateDataGrid = new DataGrid();
    DataGridTextColumn col0 = new DataGridTextColumn();
    DataGridTextColumn col1 = new DataGridTextColumn();
    DataGridCheckBoxColumn col2 = new DataGridCheckBoxColumn();
    Binding b = new Binding("checkBox");
    b.Mode = BindingMode.TwoWay;

    b.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

    taxRateDataGrid.Columns.Add(col0);
    taxRateDataGrid.Columns.Add(col1);
    taxRateDataGrid.Columns.Add(col2);

    col0.Binding = new Binding("rate");
    col1.Binding = new Binding("mark");
    col2.Binding = b;

    CheckBox c = new CheckBox();
    c.Content = "a";


    col0.Header = "Stawka";
    col1.Header = "Oznaczenie";
    col2.Header = "Status";



    taxRateDataGrid.Items.Add(new taxRateFromDatabase { rate = 0, mark = "E", c = c });
    taxRateDataGrid.Items.Add(new taxRateFromDatabase { rate = 1, mark = "G", c = c });

Problem is that I cant really check/uncheck that checkbox i have just added.
I have tried also without checkbox in struct definition (just empty datagridcheckboxcolumn), but that also doesnt work. Im creating it in class which will return datagrid so i cant really acces xaml.

Any sugestions will be appreciated 😉

  • 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-10T20:01:32+00:00Added an answer on June 10, 2026 at 8:01 pm

    I suggest you to use class instead struct (take a look here) and implement INotifyPropertyChanged interface in order to get the binding working.

    Something like

    public class TaxRateFromDatabase : INotifyPropertyChanged
            {
                private int _rate;
                public int Rate
                {
                    get { return _rate; }
                    set { _rate = value; OnPropertyChanged("Rate"); }
                }
    
                private string _mark;
                public string Mark
                {
                    get { return _mark; }
                    set { _mark = value; OnPropertyChanged("Mark"); }
                }
    
                private bool _isChecked;
                public bool IsChecked
                {
                    get { return _isChecked; }
                    set { _isChecked = value; OnPropertyChanged("IsChecked"); }
                }
    
    
    
    
    
                public event PropertyChangedEventHandler PropertyChanged;
                private void OnPropertyChanged(string propertyName)
                {
                    if (PropertyChanged != null)
                        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
    
            }
    

    and for example

    DataGrid taxRateDataGrid = new DataGrid();
            DataGridTextColumn col0 = new DataGridTextColumn();
            DataGridTextColumn col1 = new DataGridTextColumn();
            DataGridCheckBoxColumn col2 = new DataGridCheckBoxColumn();
    
    
            taxRateDataGrid.Columns.Add(col0);
            taxRateDataGrid.Columns.Add(col1);
            taxRateDataGrid.Columns.Add(col2);
    
            col0.Binding = new Binding("Rate");
            col1.Binding = new Binding("Mark");
            col2.Binding = new Binding("IsChecked");
    
            col0.Header = "Stawka";
            col1.Header = "Oznaczenie";
            col2.Header = "Status";
    
    
            List<TaxRateFromDatabase> list = new List<TaxRateFromDatabase>();
    
    
            list.Add(new TaxRateFromDatabase { Rate = 1, Mark = "E", IsChecked = true });
            list.Add(new TaxRateFromDatabase { Rate = 23, Mark = "F", IsChecked = false });
    
            taxRateDataGrid.ItemsSource = list;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got problem with this method: public List<int> menu_wid_w_kat() { DataSet1TableAdapters.menu_widac_wszystkoTableAdapter pk =
I've got a strange problem with WPFToolkit DataGrid - after disabling AutoGenerateColumns , after
I've got problem using generics. I'm creating an interface called IProblem , where each
I´ve got a special problem, that first seems very easy but I don´t know
I got this itching problem and I cant get the code to work How
I've got a strange problem here regarding sorting of a WPF DataGrid (System.Windows.Controls.DataGrid in
I've got a Datagrid/Dataform setup with a Datapager as well. My DataPager.PageSize is set
ive got problem with update. here is mysql query.log 25474 Query UPDATE db_mail4u.dMailerQueue SET
I've got problem with dropping foreign key index, I always get the same error
Got problem with PDOStatement->fetch under symfony (v1.4.6) as while fetching records from statement first

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.