在WPF中包含集合的控件(例如
ListBox
或
ComboBox
使用
TextBlock
使用值类型(如
int
或
enum
)
可验证示例:
XAML代码:
<Window.Resources>
<Style TargetType="ComboBox">
<Setter Property="FontSize" Value="8"/>
<Setter Property="Height" Value="25"/>
<Setter Property="Foreground" Value="Green" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="50"/>
<Setter Property="Foreground" Value="Red" />
</Style>
</Window.Resources>
<Grid>
<ComboBox Name="cbb1" Margin="0 -100 0 0"/>
<ComboBox Name="cbb2"/>
</Grid>
CS代码:
//In the constructor
cbb1.ItemsSource = new[] { "A", "B", "C" };
cbb1.SelectedItem = cbb1.Items[0];
cbb2.ItemsSource = new[] { 1, 2, 3 };
cbb2.SelectedItem = cbb2.Items[0];
此示例代码将显示2
组合框
's,其中项具有'incorrect'
控件
造型和其他将有“正常”
组合框
造型。
其他,然后为所需的值类型(最常见的是
枚举
对于我来说)或者删除样式是否有解决方法或修复方法?