Reputation: 55
I have some quick icons which make my software easy to use. But now as per my client requirements, I need to make these icons a Dropdown. Does anyone have some idea how to do this?
I have tried the normal combo box code XAML. But cannot add images. Is there any better way in code-behind or DbModels?
<ComboBox HorizontalAlignment="Center" Grid.Row="2"
Grid.Column="5" x:Name="DropDownSearchMode" Style="{StaticResource
ComboBoxStyle}">
<ComboBoxItem Content="X"/>
<ComboBoxItem Content="Y"/>
<ComboBoxItem Content="Z"/>
</ComboBox>
Instead of X, Y, and Z, I want some icons to display a drop-down. Can anyone help me?
Upvotes: 2
Views: 770
Reputation: 7667
Like this:
<StackPanel Margin="10">
<ComboBox>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="red.png" />
<TextBlock Foreground="Red">Red</TextBlock>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="green.png" />
<TextBlock Foreground="Green">Green</TextBlock>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="blue.png" />
<TextBlock Foreground="Blue">Blue</TextBlock>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
Upvotes: 2