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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:20:29+00:00 2026-06-18T18:20:29+00:00

I need create a custom combobox control that allows header as separator which should

  • 0

I need create a custom combobox control that allows header as separator which should not be selectable using the mouse move or key press.

this is example:

Header1
  item1
  item2
  item3
Header2
  item4
  item5

I tried many solutions, without success. Thanks in advance!

  • 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-18T18:20:30+00:00Added an answer on June 18, 2026 at 6:20 pm

    Once again, WPF can easily provide solutions that would require tons of horrible hacks in winforms.

    Copy and paste my code in a File -> New Project -> WPF Application in Visual Studio.

    You will quickly notice that my solution not only provides a different visual appearance for Header Items, but it also prevents unwanted selection, be it via mouse or keyboard, and it doesn’t need to subclass the regular ComboBox class, which would lead to lesser maintainability.

    ComboBox

    XAML:

    <Window x:Class="WpfApplication5.Window2"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:WpfApplication5"
            Title="Window2" Height="300" Width="300">
        <Grid>
            <ComboBox ItemsSource="{Binding}" DisplayMemberPath="DisplayText"
                      VerticalAlignment="Center" HorizontalAlignment="Center" 
                      Height="25" Width="100">
                <ComboBox.ItemContainerStyle>
                    <Style TargetType="ComboBoxItem">
                        <Setter Property="Foreground" Value="Black"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsHeader}" Value="True">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Setter Property="FontWeight" Value="Bold"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding IsHeader}" Value="False">
                                <Setter Property="Margin" Value="10,0,0,0"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ComboBox.ItemContainerStyle>
            </ComboBox>
        </Grid>
    </Window>
    

    Code Behind:

    using System.Collections.Generic;
    using System.Windows;
    
    namespace WpfApplication5
    {
        public partial class Window2 : Window
        {
            public Window2()
            {
                InitializeComponent();
    
                var list = new List<ComboBoxItem>
                    {
                        new ComboBoxItem {DisplayText = "Header1", IsHeader = true},
                        new ComboBoxItem {DisplayText = "Item1", IsHeader = false},
                        new ComboBoxItem {DisplayText = "Item2", IsHeader = false},
                        new ComboBoxItem {DisplayText = "Item3", IsHeader = false},
                        new ComboBoxItem {DisplayText = "Header2", IsHeader = true},
                        new ComboBoxItem {DisplayText = "Item4", IsHeader = false},
                        new ComboBoxItem {DisplayText = "Item5", IsHeader = false},
                        new ComboBoxItem {DisplayText = "Item6", IsHeader = false},
                    };
    
                DataContext = list;
            }
        }
    
        public class ComboBoxItem
        {
            public string DisplayText { get; set; }
            public bool IsHeader { get; set; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a custom TextBox control that allows user input HTML tags.
Need to create a custom DNS name server using C which will check against
I need to create a custom user interface using extJS/JSP which will allow me
I have a requirement where i need to create the custom header which has
I need to create a custom control containing a combobox whose popup will have
I would like to create a custom WPF control that inherits from comboBox. So
I need to create a custom button control that will inherit from the same
I need to create a custom json for the jit library. Should I use
I need to create a custom component which consist of a drop down box,
I need to create a custom view, which extends RelativeLayout and simply needs to

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.