I want to have a control similar to this? Is there a way to do this using WPF.
Sample Image:
It is like a combobox but its comboboxitems works as menuitems. The menu item selected would be displayed in the combobox.
I want to have a control similar to this? Is there a way to do this using WPF.
Sample Image:
It is like a combobox but its comboboxitems works as menuitems. The menu item selected would be displayed in the combobox.
I can confirm that there is no direct way to do this. The only workaround is to set up a Menu (with one big MenuItem) to make it look like a ComboBox. Here is the code before any DataBindings:
<Menu HorizontalAlignment="Left">
<MenuItem>
<MenuItem.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="140"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Stretch" Content="Select"/>
<Border Grid.Column="1" HorizontalAlignment="Right">
<ToggleButton IsChecked="False" IsHitTestVisible="False"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}">
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Focusable" Value="False" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Path Data="M0,0L3.5,4 7,0z" Fill="#FF000000" Name="Arrow"
Margin="3,1,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
</Border>
</Grid>
</MenuItem.Header>
<MenuItem Header="_Name">
<MenuItem Header="_Last" />
<MenuItem Header="_First" />
</MenuItem>
</MenuItem>
If you need menu item then use menu item. I think it would be much harder to customize combobox.