1、枚举类型
public enum Weeks
{
星期一,
星期二,
星期三,
星期四,
星期五,
星期六,
星期日
}
2、前端
<StackPanel>
<ComboBox x:Name="cbbDemo" Height="35" Width="200" VerticalContentAlignment="Center" HorizontalAlignment="Left"
SelectionChanged="cbbDemo_SelectionChanged"></ComboBox>
<TextBlock x:Name="tbDemo" Height="50" VerticalAlignment="Center"></TextBlock>
</StackPanel>
3、后端
public MainWindow()
{
InitializeComponent();
cbbDemo.ItemsSource=Enum.GetValues(typeof(Weeks));
}
private void cbbDemo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
string str=cbbDemo.SelectedItem.ToString();
tbDemo.Text="你选择的是:"+str;
}