[英]Change style of existing theme (AvalonDock)
I want to change the Metro theme color of AvalonDock.我想更改 AvalonDock 的 Metro 主题颜色。 I also asked a related question on Codeplex but I didn't got an answer so far.
我也在Codeplex 上问了一个相关的问题,但到目前为止我还没有得到答案。
I identified the following XAML ( source file ) as the piece that, I guess, is responsible for the color I want to change:我确定了以下 XAML( 源文件)作为我想改变颜色的部分:
<Style TargetType="avalonDockControls:AnchorablePaneTitle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
...
<ControlTemplate.Triggers>
...
<DataTrigger Binding="{Binding Model.IsActive, RelativeSource={RelativeSource Mode=Self}}" Value="True">
<!-- following XAML line -->
<Setter Property="BorderBrush" Value="{DynamicResource AvalonDock_ThemeMetro_BaseColor3}" />
<Setter Property="BorderThickness" Value="0,3,0,0"/>
</DataTrigger>
...
</ControlTemplate.Triggers>
...
You can see: the brush gets the BaseColor3 (a bluish color by default).您可以看到:画笔获得了 BaseColor3(默认为蓝色)。
Now I changed the color like that in my XAML:现在我更改了 XAML 中的颜色:
<Window.Resources>
...
<SolidColorBrush x:Key="AvalonDock_ThemeMetroBaseColor3" Color="Red" />
</Window.Resources>
Nothing changes.没有什么改变。 The color stay bluish.
颜色保持蓝色。 Now I am confused.
现在我很困惑。 So it must be the wrong property to change or something prevents the color to change or/and internal it uses the old value or something...
因此,更改必须是错误的属性,或者某些东西会阻止颜色更改或/和内部使用旧值或其他东西...
Why is it not working?为什么它不起作用? How can I discover such problems and fix it?
我怎样才能发现这些问题并解决它?
I guess the problem was this:我想问题是这样的:
<avalon:DockingManager>
<avalon:DockingManager.Theme>
<avalon:MetroTheme />
</avalon:DockingManager.Theme>
...
</avalon:DockingManager>
I removed the theme setting and created an own Resource dictionary (copied the style from the AvalonDock source).我删除了主题设置并创建了自己的资源字典(从 AvalonDock 源中复制了样式)。 I had to fix some errors:
我不得不修复一些错误:
BasedOn="{Static Resource {x:Type MenuItem}}"
(caused an error)BasedOn="{Static Resource {x:Type MenuItem}}"
(导致错误)After that it worked.在那之后它起作用了。
The solution seems to be adding the SolidColorBrush to the DockingManager resources in the xaml file.解决方案似乎是将 SolidColorBrush 添加到 xaml 文件中的 DockingManager 资源中。
<avalonDock:DockingManager Grid.Row="1" x:Name="DockingManager">
<avalonDock:DockingManager.Resources>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor1" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor3" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor4" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor5" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor8" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor9" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor10" Color="Red"/>
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor11" Color="Red" />
<SolidColorBrush x:Key="AvalonDock_Expression_BaseColor13" Color="Red"/>
</avalonDock:DockingManager.Resources>
<avalonDock:DockingManager.Theme>
<avalonDock:ExpressionDarkTheme/>
</avalonDock:DockingManager.Theme>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.