我想阻止用戶編輯/選擇組合框。我嘗試使用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)。 –