RibbonCombobox:更改颜色后出现橙色边框

时间:2015-01-19 14:27:16

标签: c# wpf ribbon

我有一个简单的功能区组合框(用于WPF的MS功能区),并试图改变它的风格。 当我将属性“PressedBackground”和“PressedBorderBrush”设置为任何颜色时,会出现橙色边框。

见截图:

enter image description here

XAML:

<ribbon:RibbonComboBox SelectionBoxWidth="110" PressedBackground="Blue" PressedBorderBrush="Black">
    <ribbon:RibbonGallery></ribbon:RibbonGallery>                                                    
</ribbon:RibbonComboBox>       

删除此边框的任何想法?

1 个答案:

答案 0 :(得分:0)

为了改变它你必须编辑RibbonComboBox模板并改变橙色边框出现的位置,为此我更喜欢使用Blend或Vs设计师:

选择RibbonComboBox控件,

在属性窗口中将RibbonComboBox转换为本地资源:

enter image description here

IsChecked Trigger下更改渐变橙色的InnerBorder

<Trigger Property="IsChecked" Value="True">
 <Setter Property="Background" TargetName="OuterBorder" Value="{Binding CheckedBackground, RelativeSource={RelativeSource TemplatedParent}}"/>
 <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{Binding CheckedBorderBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
 <Setter Property="BorderBrush" TargetName="InnerBorder">
  <Setter.Value>
    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
     <GradientStop Color="#FFE7CBAD" Offset="0"/>
     <GradientStop Color="#FFF7D7B5" Offset="0.1"/>
     <GradientStop Color="#FFFFD38C" Offset="0.36"/>
     <GradientStop Color="#FFFFC75A" Offset="0.36"/>
     <GradientStop Color="#FFFFEFA5" Offset="1"/>
    </LinearGradientBrush>
  </Setter.Value>
 </Setter>
</Trigger>

你想要的任何颜色:

<Trigger Property="IsChecked" Value="True">
 <Setter Property="Background" TargetName="OuterBorder" Value="{Binding CheckedBackground, RelativeSource={RelativeSource TemplatedParent}}"/>
 <Setter Property="BorderBrush" TargetName="OuterBorder" Value="{Binding CheckedBorderBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
 <Setter Property="BorderBrush" TargetName="InnerBorder">
 <Setter.Value>
  <SolidColorBrush Color="Red"></SolidColorBrush>
</Setter.Value>

输出:

enter image description here