user1028741
user1028741

Reputation: 2815

WPF: how to create a combo with sub-items?

I want to use a combobox which has some items, and also sub-items.

Specifically, I want to add a "more..." item in the end of the list, which on hover will lead to additional options.

Please see an example to what I want from windows's menus: enter image description here

Do you have an idea about how can I achieve this?

(Tried to do using combobox - but I don't know how to create subitems there).

Upvotes: 0

Views: 1799

Answers (2)

Vinaya Joseph
Vinaya Joseph

Reputation: 1

use menu in wpf for displaying items and subitems.below link will help you

http://www.wpf-tutorial.com/common-interface-controls/menu-control/

Upvotes: 0

Adeeb Arangodan
Adeeb Arangodan

Reputation: 152

You can use menus for the same purpose. Menus can be placed where ever you want in WPF. Have you tried with Menus?

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

    <Menu Grid.Row="1" Grid.Column="1" Width="100" VerticalAlignment="Center" Background="Gray">
        <MenuItem Header="Item Collection">
            <MenuItem Header="Item 1"></MenuItem>
            <MenuItem Header="Item 2"></MenuItem>
            <MenuItem Header="Sub Items">
                <MenuItem Header="SubItem 1"></MenuItem>
                <MenuItem Header="SubItem 2"></MenuItem>
            </MenuItem>
        </MenuItem>
    </Menu>
</Grid>

enter image description here

Upvotes: 2

Related Questions