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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:23:23+00:00 2026-05-24T09:23:23+00:00

radio.Checked += new RoutedEventHandler(VariantChecked); assuming I have this code. What if I want to

  • 0

radio.Checked += new RoutedEventHandler(VariantChecked);
assuming I have this code. What if I want to pass an argument to VariantChecked method. What syntax should I apply?

  • 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-24T09:23:24+00:00Added an answer on May 24, 2026 at 9:23 am

    During creation, attach your data object to the DataContext or the Tag property of the RadioButton.

    RadioButton radio=new RadioButton();
    radio.DataContext=yourData;
    

    Then in the event handler, get the data back:

    void VariantChecked(object sender, RoutedEventArgs e){ 
       RadioButton  radio=(RadioButton)sender; 
       YourData yourData=(YourData)radio.DataContext; 
    }
    

    In the above example I have assumed that you have a class or struct named YourData that you want to provide. You can replace this through any primitive like string or int or any other object type.


    The above works also from xaml:

    <RadioButton Tag="Static Data, could also be a binding" ...
    

    Here I have taken the Tag property because it makes for such a construction more sense, but DataContext could also be taken. The event handler is the same except for casting from the Tag-property.

    void VariantChecked(object sender, RoutedEventArgs e){    
       RadioButton  radio=(RadioButton)sender;    
       string yourStringFromTag=(string)radio.Tag; 
    }
    

    By the way, you can make the code more generic by not specify a concrete control-class but a base class:

    void VariantChecked(object sender, RoutedEventArgs e){    
       FrameworkElement fe=(FrameworkElement)sender;    
       string yourStringFromTag=(string)fe.Tag; 
    }
    

    Hope this helped…

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

Sidebar

Related Questions

In my page I have three radio buttons and I want to checked the
i have this code below to show different divs when i choose certain radio
I have a problem selecting a checked radio button with jquery. The radio buttons
http://developer.yahoo.com/yui/button More specifically, I want radio buttons. that can be checked/unchecked.
I have a seemingly easy task of setting a radio button checked based on
I have 2 radio buttons and 4 check boxes that i want to keep
I have the following markup, and I want to make the All radio button
I have used this custom Helper in My Razor View. @Html.Link(OpenewWindow, Constants.Value, new {
Looking for something like: $(input:radio:checked).previous(name, original_name).attr(name,new_name); I tried a few different seen around here
How to set radio option checked onload with jQuery? Need to check if no

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.