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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:47:21+00:00 2026-06-18T08:47:21+00:00

I am building a view in WPF, which is supposed to have a quite

  • 0

I am building a view in WPF, which is supposed to have a quite complex ComboBox, using MVVM pattern with Caliburn.Micro framework. I’m quite new to WPF and Caliburn and I hope I can find the right answer here.

This is what I imagine:
Expanded ComboBox

As you can see, it consists of different kinds of items and different child levels. Only items are selectable, not their groups. In addition to that, I would like to display two additional buttons on the combobox, that depend on the item group the selected item belongs to:
Shrunken Combobox

I know I could:

  • Hardcode the combobox in XAML to look like this, but it doesn’t really work for me as I need to have the data in my view model.
  • Programmatically define the control tree in my view model and bind my combobox’s content property to it. But it seems a bit wrong to create visuals in my view model.
  • Create a view model (and a view) for combobox items and set various properties to control the way each of them looks.
  • Create a completely new control, derived from ComboBox and implement this somehow.

As for the two buttons, I could probably put them on top of the combobox and control their visibility from the main view model.

Having considered all these options, I’m still not confident I know what I’m doing here.

  • 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-18T08:47:23+00:00Added an answer on June 18, 2026 at 8:47 am

    You can restyle a ComboBox using templates to get the look you are after.
    Here is a quick example:

    XAML

    <ComboBox Width="200" Height="30" ItemsSource="{Binding ItemList}">
        <ComboBox.ItemContainerStyle>
            <Style>
                <Setter Property="UIElement.IsEnabled" Value="{Binding IsSelectable}" />
            </Style>
        </ComboBox.ItemContainerStyle>
        <ComboBox.ItemTemplate>
            <DataTemplate >
                <StackPanel Orientation="Horizontal">
                    <Image Name="ImageControl" Source="{Binding ImagePath}" Width="10" Height="10" />
                    <Label Content="{Binding Name}" >
                        <Label.Style>
                            <Style TargetType="Label">
                                <Style.Triggers>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter Property="Foreground" Value="Black" />
                                        <Setter Property="FontWeight" Value="Bold" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Label.Style>
                    </Label>
                </StackPanel>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsSelectable}" Value="False">
                        <Setter TargetName="ImageControl" Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
    

    C#

    // A class to hold my data for the combobox
    public class Item
    {
        public string Name { get; set; }
        public bool IsSelectable { get; set; }
        public string ImagePath { get; set; }
    }
    
    // In your datacontext
    public ObservableCollection<Item> ItemList { get; set; }
    
    public ComboBoxFun()
    {
        ItemList = new ObservableCollection<Item>()
        {
            new Item() { ImagePath=@"/images/up.png", Name="Item Group 1", IsSelectable=false},
            new Item() { ImagePath=@"/images/up.png", Name="Item 1", IsSelectable=true},
            new Item() { ImagePath=@"/images/up.png", Name="Item 2", IsSelectable=true},
            new Item() { ImagePath=@"/images/up.png", Name="Item 3", IsSelectable=true},
            new Item() { ImagePath=@"/images/up.png", Name="Item Group 2", IsSelectable=false},
            new Item() { ImagePath=@"/images/up.png", Name="Item 1", IsSelectable=true},
            new Item() { ImagePath=@"/images/up.png", Name="Item 2", IsSelectable=true},
            new Item() { ImagePath=@"/images/up.png", Name="Item 3", IsSelectable=true}
        };
    

    The only tricky part is that when you disable an item it will be styled as disabled, so you have to style the non-selectable items so they appear normal.

    Here is my result:

    Results

    You can select any non-group item, and it works like a normal ComboBox.
    As for you buttons, you can simply control the visibility of them based on the selected item’s data.

    Hope this helps.

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

Sidebar

Related Questions

I’m building a WPF application using MVVM pattern (both are new technologies for me).
I am building an wpf app using MVVM. I have viewModels the employ lazy
I am building a WPF app that is based on the MVVM pattern (using
I'm building an application using the Supervising Controller pattern (Model View Presenter) and I
I am using the Model-View-ViewModel architecture in a WPF application I am building, and
hello i'm building a wpf app with data grids, the pattern is model view
I'm building an application using WPF and MVVM. I've come across a situation where
I'm building a WPF application in which I have a need to get the
I am building a waterfall view just like pinterest. Now I have to explicitly
I am building an Day View calendar app. I have already created the empty

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.