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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:09:03+00:00 2026-06-13T23:09:03+00:00

I have a ComboBox control inside Context menu for some Label Control that I

  • 0

I have a ComboBox control inside Context menu for some Label Control that I have added in Code behind in wpf application. There are many Labels on the page that have Contextmenu. Basically it is like this LABEL contains ContextMenu and ContextMenu conntains Combobox. On Combobox’s SelectionChanged event I want to know which label’s contextmenu’s Combobox has generated this event?

  • 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-13T23:09:04+00:00Added an answer on June 13, 2026 at 11:09 pm

    You can get the ComboBox from the sender argument in the eventhandler.

    You can then get the ContextMenu from the Parent property on the ComboBox.

    And then finally the Label from the PlacementTarget property on the ContextMenu.

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
    
            var label = new Label();
            label.Content = "Click me!";
            label.Name = "clickMe";
            this.Content = label;
    
            var cmb = new ComboBox();
            cmb.Name = "combobox1";
            cmb.Items.Add("Test1");
            cmb.Items.Add("Test2");
            cmb.Items.Add("Test3");
            cmb.SelectionChanged += new SelectionChangedEventHandler(cmb_SelectionChanged);
    
            var menu = new ContextMenu();
            menu.Name = "contextmenu";
            menu.Items.Add(cmb);
    
            label.ContextMenu = menu;
        }
    
        private void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var cmb = (ComboBox)sender;
            var contextmenu = (ContextMenu)cmb.Parent;
            var label = (Label)contextmenu.PlacementTarget;
    
            MessageBox.Show("Combobox: " + cmb.Name + Environment.NewLine +
                            "Contextmenu: " + contextmenu.Name + Environment.NewLine +
                            "Label: " + label.Name);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this filtered WPF ComboBox control from Diederik Krols. I have found that
If I have a control (combobox, with a SelectionChanged-event in code-behind) in DataGrid. So,
I have a wpf cusotm control derived from combobox System.Windows.Controls.ComboBox the control template is
I have a Panel control. And inside the panel users can add combobox's, textbox's
I have a custom control in WPF that simply holds a combo box (however
I have a whole bunch of code that is dependent on the ComboBox type,
I have a form in my WPF application that I have to add an
I have the following inside a user control called UserInputOutput : <ComboBox Grid.Column=1 Background=White
I have a WPF combobox control bound to a edm field in a database
I have a FlowDocument in a standard WPF application window where I have some

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.