Telerik控件使用Expression_DarkTheme后引发Combobx下拉问题
之前在Telerik的官方论坛中发现了有人提出该问题,但官方并未给出解决方案。
官方的回应应该是说Telerik版本问题,但实际上应该不是,我也换到了最新的版本依然会有问题。
没有办法,只能另外定一个全局样式临时性解决该问题。解决方案如下:
其实就是按样式重写一下RadComboBoxItem的样式即可,把Resource加入到App.xaml当中去。
1 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 2 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 3 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> 4 5 <!--重写Combobox下拉菜单样式--> 6 <SolidColorBrush x:Key="ItemBackground_Selected" Color="#FF878787" /> 7 <SolidColorBrush x:Key="ItemForeground_Selected" Color="#FF262626" /> 8 <ControlTemplate x:Key="RadComboBoxItemTemplate" TargetType="telerik:RadComboBoxItem"> 9 <Border x:Name="Background" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> 10 <VisualStateManager.VisualStateGroups> 11 <VisualStateGroup x:Name="CommonStates"> 12 <VisualState x:Name="Normal" /> 13 <VisualState x:Name="MouseOver"> 14 <Storyboard> 15 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Highlight" Storyboard.TargetProperty="(UIElement.Visibility)"> 16 <DiscreteObjectKeyFrame KeyTime="0:0:0"> 17 <DiscreteObjectKeyFrame.Value> 18 <Visibility>Visible</Visibility> 19 </DiscreteObjectKeyFrame.Value> 20 </DiscreteObjectKeyFrame> 21 </ObjectAnimationUsingKeyFrames> 22 <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="(ContentControl.Foreground)"> 23 <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource ItemForeground_Selected}" /> 24 </ObjectAnimationUsingKeyFrames> 25 </Storyboard> 26 </VisualState> 27 <VisualState x:Name="Disabled" /> 28 </VisualStateGroup> 29 </VisualStateManager.VisualStateGroups> 30 <Grid> 31 <Rectangle x:Name="Highlight" Fill="{StaticResource ItemBackground_Selected}" Visibility="Collapsed" /> 32 <ContentPresenter x:Name="Content" Margin="{TemplateBinding Padding}" 33 HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 34 VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> 35 </Grid> 36 </Border> 37 </ControlTemplate> 38 39 <Style x:Key="RadComboBoxItemStyle" TargetType="telerik:RadComboBoxItem"> 40 <Setter Property="Background" Value="Transparent" /> 41 <Setter Property="Template" Value="{StaticResource RadComboBoxItemTemplate}" /> 42 <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 43 <Setter Property="VerticalContentAlignment" Value="Stretch" /> 44 <Setter Property="Padding" Value="3 6" /> 45 <Setter Property="FocusVisualStyle" Value="{x:Null}" /> 46 </Style> 47 <Style TargetType="telerik:RadComboBoxItem" BasedOn="{StaticResource RadComboBoxItemStyle}" /> 48 </ResourceDictionary>