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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:55:03+00:00 2026-05-24T21:55:03+00:00

I’m trying to use a datagrid binded to a collection of objects with two

  • 0

I’m trying to use a datagrid binded to a collection of objects with two parameters. The datagrid has to allow me to insert new rows, thus to create new objects.

The first column, binded to the first parameter, is a text column.
The second one, should be a template column, containing a radiobutton which uses a BoolToInt converter (not relevant) for setting the value to the second property.

When displaying the already existing rows in the grid, it also displays an empty row used for inserting a new object. Thus, we have two posibilities of inserting a new object in the list/grid:
1. We first type something in the text column and then we check the radiobutton
2. First we check the radiobutton and then we type something in the text column

The first option, works just fine. The second one doesn’t:
When i check the radiobutton and then go and type something in the text column, the radiobutton just gets unchecked. Actually it disappears because when I start typing text, a new row is created in the grid, with a new radiobutton. The one I first checked is just the one on the empty row allowing me to add new rows and it keeps going to the bottom of the list whenever i insert a new row.

I think this should be solved by forcing the grid to create a new row when checking the radiobutton, just as it does when typing in a text column.

This is the datagrid:

<DataGrid ItemsSource="{Binding Path=Rows}" AutoGenerateColumns="False">
        <DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding Path=param1, TargetNullValue=''}">
            </DataGridTextColumn>
            <DataGridTemplateColumn>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <RadioButton VerticalAlignment="Center" IsChecked="{Binding Path=param2, Converter={StaticResource RPLBoolToIntConverter}, ConverterParameter=1}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>            
    </DataGrid>

And this is the code behind, creating some objects to display:

CPL cpl = new CPL();            
        cpl.Rows = new List<CPLRow>()
        {
            new CPLRow(){ param1=80001, param2=20304},
            new CPLRow(){ param1=80002, param2=20304},
            new CPLRow(){ param1=80003, param2=20304}
        };
        DataContext = cpl;

Is there any way to make it react to checking the radiobutton. I’m thinking of an example where I would like to just use radiobuttons and whenever I check one, a new row gets created while still correctly binding to the collection.

Thanks in advance!

  • 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-24T21:55:04+00:00Added an answer on May 24, 2026 at 9:55 pm

    I don’t agree with your statement the one I just checked is now on the next empty row. It is still the same button but there is another row. I think you problem is the check/check event is not firing until the button loses focus (e.g. you go the the textbox). In the binding you need to set UpdateSourceTrigger=PropertyChanged.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace

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.