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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:20:33+00:00 2026-05-21T12:20:33+00:00

In WPF I have a stack panel whose items control defines a data template.

  • 0

In WPF I have a stack panel whose items control defines a data template. This data template is a radio button. The items source is a collection of names on my view model.

So for each name in the view model, a radio button appears on the stack panel with the text beside it for that name (using the content property).

All of these radio buttons have the group set to “name” so selection is mutually exclusive.

My question is, what are my options for binding the content of the selected radio button to a property on my view model “selectedName”?

Ideally I want a UI binding, that is code-free.

Thankyou

  • 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-21T12:20:34+00:00Added an answer on May 21, 2026 at 12:20 pm

    I am not sure if you can make use of the mutually exclusiveness there without any event handling. Normally i have this problem with MenuItems or button groups and my approach is to use Multibindings with a EqualityConverter, e.g.

    <Setter Property="IsChecked">
        <Setter.Value>
            <MultiBinding Converter="{StaticResource EqualityComparisonConverter}" Mode="OneWay">
                <!-- This binding should find your VM and bind to your property -->
                <Binding RelativeSource="{RelativeSource AncestorType=Window}"
                         Path="DataContext.SelectedName"/>
    
                <!-- Binds to the item being templated -->
                <Binding /> 
            </MultiBinding>
        </Setter.Value>
    </Setter>
    

    A converter (it’s not very safe, throws exception if one of the values is null, might want to improve it):

    public class EqualityComparisonConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members
    
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 2) throw new Exception("At least two inputs are needed for comparison");
            bool output = values.Aggregate(true, (acc, x) => acc && x.Equals(values[0]));
            return output;
        }
    
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    
        #endregion
    }
    

    Actually it’s somewhat of a mystery to me how that even works (considering that the binding is one-way)…

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

Sidebar

Related Questions

I have WPF ListBox which is bound to a ObservableCollection, when the collection changes,
I have a WPF control, that has a list of Investors, and in the
In my WPF Application I have an GridViewColumn that looks like this: <GridViewColumn Width=170>
In my WPF application I have this: <StackPanel> <TextBlock> <Hyperlink> <TextBlock TextWrapping=Wrap Name=HyperlinkText />
I have a wpf project which uses transparent windows and I share this transparent
In WPF 3.5 (with SP1), I have simply StackPanel that I would like to
I am a newbie to WPF and have a couple of questions about WPF
I'm making my first foray into WPF - I have a simple form with
I have a WPF project and I'm trying to setup a NAnt build script
I have a WPF application in VS 2008 with some web service references. For

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.