In this article I am going to show how we can use combo
box in WPF. How we can show selected value in message box. How we can customize
our combo box.
Below is my XAML code..
<Window x:Class="ComboBoxInWPF.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<ComboBox Margin="10,10,0,13" Name="ComboBox1" HorizontalAlignment="Left"
VerticalAlignment="Top" Width="194" Height="30"
SelectionChanged="ComboBox1_SelectionChanged">
<ComboBoxItem Background="LightCoral" Foreground="#00008B" Content="Cricket"
FontFamily="Verdana" FontSize="12" FontWeight="Bold" IsSelected="True"></ComboBoxItem>
<ComboBoxItem Background="LightGray" Foreground="#006400" Content="Football"
FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ComboBoxItem>
<ComboBoxItem Background="LightBlue" Foreground="#FF1493" Content="Tennis"
FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ComboBoxItem>
<ComboBoxItem Background="LightGreen" Foreground="#FF00FF" Content="Hockey"
FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ComboBoxItem>
<ComboBoxItem Background="LightBlue" Foreground="#ADFF2F" Content="Volleyball"
FontFamily="Verdana" FontSize="12" FontWeight="Bold"></ComboBoxItem>
<ComboBoxItem Background="LightSlateGray" Foreground="#FFA07A" Content="Table Tennis"
FontFamily="Georgia" FontSize="14" FontWeight="Bold"></ComboBoxItem>
</ComboBox>
</Grid>
</Window>
When I run my Application then.

Figure 1.

Figure 2.