我想阻止用户编辑/选择组合框。我尝试使用cmbbox.IsReadOnly = True
和cmbbox.IsEditable = False
,它允许用户通过alt
和arrow' keys
更改选择。 cmbbox.isEnabled = False
的作品,我的要求是禁用时,将组合框前景颜色更改为“黑色”。任何人都可以请帮我解决它?如何更改禁用状态下组合框的前景?
在XAML:
<telerik:RadComboBox Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" x:Name="combobox1" IsEditable="True" IsFilteringEnabled="True" ItemsSource="{Binding}" TabIndex="7" Style="{ DynamicResource DropDownListStyle }" IsTabStop="True" KeyboardNavigation.TabNavigation ="Local" SelectAllTextEvent="None" Height="23" Margin="0,0,0,2" VerticalAlignment="Center"/>
在代码隐藏:
combobox1.IsEnabled = False
风格:
<Style x:Name="DropDownListStyle" x:Key="DropDownListStyle" TargetType="telerik:RadComboBox" >
<Setter Property="Foreground" Value="#FF000000"/>
<Setter Property="BorderBrush" Value="#ffcccccc"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="12"/>
<Setter Property="FontWeight" Value="Thin"/>
<Setter Property="FontFamily" Value="Trebuchet MS"/>
<Setter Property="Panel.ZIndex" Value="10" />
<Setter Property="Height" Value="23" />
<!-- <Setter Property="Focusable" Value="True"/> -->
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
请分享一下你的代码 –
的事实上,这将是很好的编辑您的问题,并添加到目前为止你写的代码:如何创建一个最小的,完整的,和可验证的例子?](http://stackoverflow.com/help/mcve)。 –