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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:16:34+00:00 2026-05-25T15:16:34+00:00

I have a list on my WPF xaml which contains two items. Below is

  • 0

I have a list on my WPF xaml which contains two items. Below is the Style template for each item. Now on UI this shows like a group of radio buttons(No. of radio buttons depends on no. of items in my list).

<Style x:Key="RadioButtonListBoxItemStyle" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <RadioButton FlowDirection="LeftToRight"
                                     Margin="10 15"
                                     Content="{Binding Value}"                                      
                                     GroupName="{Binding DisplayGroupName}"
                                     IsChecked="{Binding IsSelected, Mode=TwoWay}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Now I bind a list(having 2 items) using the above style template to get two radio buttons. What happens is everything works pretty fine i.e when I change the selection of radio button on UI the IsSelected property is getting updated properly to true or false depending on whether my radio is checked/un-checked. But if I try to set the list in the code manually, then from that point my binding of the radio button’s with my list is lost and nothing happen’s.

Any help on this would be great and based on my needs I have to set the list in the code manually. So is there any solution in a way that binding will not be lost even though I set the list in my code manually. Thanks.

-Ady.

  • 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-25T15:16:34+00:00Added an answer on May 25, 2026 at 3:16 pm

    This is a common problem with radio buttons in WPF, and it has to do an unusual aspect of binding, one that is marginally more feature than bug.

    The design of binding assumes that the only two things that change the value of a binding’s target property are a) actions in the UI and b) changes to the source property. If you set the target property of a binding in code – like, you explicitly set the Background of a Border, even though it has a binding – the binding decides that you know what you’re doing, and that it should just get out of the way. So it turns itself off.

    This is a pretty sensible design decision, for the most part. It’s better than throwing an exception, for instance. Most of the time, you’re not going to ever set IsEnabled in code anyway; you’ll let the binding do it. Especially if you’re using MVVM.

    Okay, so what happens if you have radio buttons in a group?

    When you check one button in the group, the WPF code that manages radio button groups unchecks all the other buttons in the group, by setting IsChecked to false in code. The binding disables itself. Oops.

    Here’s the solution: If you’re using radio buttons and binding, don’t use groups. Handle the mutual exclusion logic in your view model code. In your case, code your view models so that only one object in a collection can have IsSelected true at any given time. (Yes, this is a pain.)

    The radio buttons will still work as expected, but since the only properties being set by code are the source properties, binding won’t break.

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

Sidebar

Related Questions

I have List objects which are shown like this: www.mysite.com/lists/123 Where 123 is the
In WPF app I have a WCF service which dynamically fills a generic List
I have the following xaml which resides in a wpf user control - <Grid>
I'm implementing a wpf application which display a list of items, and provides the
I have two WPF list boxes. One is a list of lists (actually a
I have a flowdocument in WPF that looks like this: <FlowDocument xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Paragraph
I have a WPF (.NET 3.5) control which renders about 20000 rectangles. This MyControl
I have a Datatemplete for List-box Item in which I have a Grid with
In my WPF application, I have a main window (Branch.xaml) which has a button
In the entry form of my wpf application, I have a list of buttons

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.