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 7066437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:04:56+00:00 2026-05-28T05:04:56+00:00

I have a dynamic DataGrid in which one of the columns is a CheckBox.

  • 0

I have a dynamic DataGrid in which one of the columns is a CheckBox. I created a “Transactions” class in which I bind the columns of the datagrid to different properties in that class. I want my checkbox to be binded to a Property which is an integer. It is an integer because I am populating the properties from a query on to my database. The possible integers are either 1 (True) or 0 (False). Here is what I have so far to create my Database:

    private DataGridTemplateColumn GetVoidColumn()
    {
        DataGridTemplateColumn voidColumn = new DataGridTemplateColumn();
        voidColumn.Header = "Void";

        Binding bind = new Binding("Visible");
        bind.Mode = BindingMode.TwoWay;

        // Create the CheckBox
        FrameworkElementFactory voidFactory = new FrameworkElementFactory(typeof(CheckBox));
        voidFactory.SetValue(CheckBox.IsCheckedProperty, bind);
        DataTemplate voidTemplate = new DataTemplate();
        voidTemplate.VisualTree = voidFactory;

        voidColumn.CellTemplate = voidTemplate;

        return voidColumn;
    }

On my actual Datagrid, the CheckBox shows up but they are always Unchecked, even if the property is showing a 1. Even when I do my row validation, the value that shows up for the column is correct, contains a 1 or a 0 in the ItemArray of the row. Its just that the checkbox isn’t being checked in the UI for some reason. Can someone help me out with this?

  • 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-05-28T05:04:56+00:00Added an answer on May 28, 2026 at 5:04 am

    You can use Converters to convert property value 0 and 1 to false and true. Probably the IsChecked property is not understanding value 0 and 1. Create a class that implements IValueConverter and apply that converter to convert int to bool.

    Another option could be to create a property for this in your class

    public bool IsChecked
    {
       get
       {
           if(IntProperty == 0)
              return false;
           return true;
       }
       set
       {
           if(value)
              IntProperty = 1;
           else 
              IntProperty = 0;
       }
    }
    

    now instead of binding with int property bind with property above

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

Sidebar

Related Questions

Have datgrid with dynamic columns number, like that: <DataGrid DataGridCell.Selected=DataGrid_GotFocus EnableColumnVirtualization=true EnableRowVirtualization=true Name=dataGrid1 DockPanel.Dock=Top
I have a dynamic Datagrid that I have created. I am creating each column
I have a dynamic tableview which has a prototype cell with a button that,
I have a DataGrid and I want to populate a column that contains a
I have to create a XamDataGrid that shows a dynamic amount of columns for
I have dynamic json result and i want to create an object for that
In ASP.NET 3.5 I have a datagrid that is bound to a somwehat dynamic
I have a list which contains dynamic data. i.e list[0].id=0; list[1].id=1; list[2].id=2; I want
I have DataGrid with Dynamic Columns. The columns will contain ItemRendrer. I'm not familiar
I have a Datagrid thats being populated by different Arrays... (headers/columns change for the

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.