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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:46:38+00:00 2026-05-13T06:46:38+00:00

Maybe the obvious answer is that I need to use a UserControl but I’d

  • 0

Maybe the obvious answer is that I need to use a UserControl but I’d like to know if this is possible.

I want to customize a ComboBox to display an additional button. I’ve been able to create a template that renders the button next to the built-in drop down button. Now, how can I wire the Click event or access any of its properties (for example IsEnabled).

  • 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-13T06:46:39+00:00Added an answer on May 13, 2026 at 6:46 am

    You don’t need a UserControl, but you do have to inherit from ComboBox to extend it. You would write something like this:

    [TemplatePart(Name = "PART_ExtraButton", Type = typeof(Button))]
    public class ExtendedComboBox: ComboBox {
    
        private Button extraButton = new Button();
        public Button ExtraButton { get { return extraButton; } private set { extraButton = value; } }
    
        public static readonly RoutedEvent ExtraButtonClickEvent = EventManager.RegisterRoutedEvent("ExtraButtonClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ExtendedComboBox));
    
        public event RoutedEventHandler ExtraButtonClick {
            add { AddHandler(ExtraButtonClickEvent, value); }
            remove { RemoveHandler(ExtraButtonClickEvent, value); }
        }
    
        void OnExtraButtonClick(object sender, RoutedEventArgs e) {
            RaiseEvent(new RoutedEventArgs(ExtraButtonClickEvent, this));
        }
    
        public bool IsExtraButtonEnabled {
            get { return (bool)GetValue(IsExtraButtonEnabledProperty); }
            set { SetValue(IsExtraButtonEnabledProperty, value); }
        }
    
        public static readonly DependencyProperty IsExtraButtonEnabledProperty =
            DependencyProperty.Register("IsExtraButtonEnabled", typeof(bool), typeof(ExtendedComboBox), new UIPropertyMetadata(OnIsExtraButtonEnabledChanged));
    
        private static void OnIsExtraButtonEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
            ExtendedComboBox combo = (ExtendedComboBox)d;
            combo.ExtraButton.IsEnabled = (bool)e.NewValue;
        }
    
        public override void OnApplyTemplate() {
            base.OnApplyTemplate();
            var templateButton = Template.FindName("PART_ExtraButton", this) as Button;
            if(templateButton != null) {
                extraButton.Click -= OnExtraButtonClick;
                extraButton = templateButton;
                extraButton.Click += new RoutedEventHandler(OnExtraButtonClick);
                extraButton.IsEnabled = this.IsExtraButtonEnabled;
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is a little unconventional question but I'd like to hear an answer
i think i sort of know the answer to this, but there are always
Maybe I'm missing something obvious, or maybe something sinister is happening, but this seems
Being that my C++ isn't that great, this may be a really simple/obvious answer,
Maybe the answer is so obvious, I'm not seeing it, but I have a
This question may be easy and the answer obvious, but I can't seem to
This sounds like a pretty easy question to answer but I haven't been able
This may be a silly question with an obvious answer, but I've pondered it
Maybe I'm missing something obvious, but I how can I view the expression tree
Maybe I am overlooking something obvious, but I have seen in code where you

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.