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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:08:10+00:00 2026-06-13T07:08:10+00:00

I am a C++ developer and recently shifted to C#. I am working on

  • 0

I am a C++ developer and recently shifted to C#. I am working on a WPF app where I need to dynamically generate 4 radio buttons. I tried to do lot of RnD but looks like this scenario is rare.

XAML:

<RadioButton Content="Base 0x" Height="16" Name="radioButton1" Width="80" />

Now here is the scenario: I should generate this radio button 4 times with different Content as follows:

<RadioButton Content = Base 0x0 />
<RadioButton Content = Base 0x40 />
<RadioButton Content = Base 0x80 />
<RadioButton Content = Base 0xc0 />

I had done this in my C++ application as follows:

#define MAX_FPGA_REGISTERS 0x40;

for(i = 0; i < 4; i++)
{
    m_registerBase[i] = new ToggleButton(String(T("Base 0x")) + String::toHexString(i * MAX_FPGA_REGISTERS));       
    addAndMakeVisible(m_registerBase[i]);
    m_registerBase[i]->addButtonListener(this);
}
m_registerBase[0]->setToggleState(true); 

If you notice above, Every-time for loop runs Content name becomes Base 0x0, Base 0x40, base 0x80 and base 0xc0 and sets the toggle state of first radiobutton as true. Thus if you notice there will be single button click method for all these 4 buttons and based on index each will perform operation.

How can i achieve this in my WPF app? 🙂

  • 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-13T07:08:11+00:00Added an answer on June 13, 2026 at 7:08 am

    I was going to write a set of code for you, but realized your question is probably already answered here:
    WPF/C# – example for programmatically create & use Radio Buttons

    It’s probably the cleanest way of doing it, depending on your requirements of course. If you want the simplest case, here it is:

    Xaml:

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
        <Grid >
            <StackPanel x:Name="MyStackPanel" />
    
        </Grid>
    </Window>
    

    C#:

        public MainWindow()
        {
            InitializeComponent();
    
            for (int i = 0; i < 4; i++)
            {
                RadioButton rb = new RadioButton() { Content = "Radio button " + i, IsChecked = i == 0  };
                rb.Checked += (sender, args) => 
                {
                    Console.WriteLine("Pressed " + ( sender as RadioButton ).Tag );
                };
                rb.Unchecked += (sender, args) => { /* Do stuff */ };
                rb.Tag = i;
    
                MyStackPanel.Children.Add( rb );
            }
        }
    

    Just add in whatever logic you need for the content, tags and so on.

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

Sidebar

Related Questions

I am a C++ developer and recently started working on C# WPF app. I
I am a C++ developer and I recently shifted to C#. I am working
I am a C++ developer and recently started working on WPF. Well I am
I'm primarily a C++ developer, but recently I've been working on a project in
I am a .Net developer but recently shifted to PHP world. I have worked
I've been a PHP developer but recently need to work on some project using
I am a C++ developer and i recently shifted to C# WPF. I am
I am a c++ developer and recently shifted to this amazing WPF world. I
I am a C++ developer and recently shifted to the world of WPF C#.
I recently upgraded to Oracle Sql Developer 2.1 It's far better, but the query

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.