相关疑难解决方法(0)

蒙皮:使用Color作为另一种颜色的StaticResource

我在我的应用程序中实现了皮肤.应用程序加载其Brushes.xaml资源字典,该字典使用驻留在特定于皮肤的资源字典中的颜色.因此,根据所选皮肤,仅加载一个Color.xaml.

皮肤特异性Color.xaml

    <Color x:Key="TextBoxBackgroundColor">#C4AF8D</Color>
    <Color x:Key="TextBoxForegroundColor">#6B4E2C</Color>
    <Color x:Key="ToolBarButtonForegroundColor">#6B4E2C</Color>
Run Code Online (Sandbox Code Playgroud)

Brushes.xaml:

    <SolidColorBrush 
        x:Key="TextBoxBackground" 
        Color="{DynamicResource TextBoxBackgroundColor}" />
    <SolidColorBrush 
        x:Key="TextBoxForeground" 
        Color="{DynamicResource TextBoxForegroundColor}" />
Run Code Online (Sandbox Code Playgroud)

如您所见,多种颜色(TextBoxForegroundColor和ToolBarButtonForegroundColor)是相同的.我想绕过它,因为它变得越来越混乱,特别是因为使用的颜色不能通过它们的十六进制值识别.您现在可以建议将两种颜色合并为一种,但我有一些皮肤,其中TextBoxForegroundColor与ToolBarButtonForegroundColor不同.

我想做的是这样的事情:

<Color x:Key="DarkBrown">#C4AF8D</Color>

<Color x:Key="TextBoxBackgroundColor" Color={StaticResource DarkBrown} />
<Color x:Key="ToolBarButtonForegroundColor" Color={StaticResource DarkBrown} />
Run Code Online (Sandbox Code Playgroud)

这在Xaml中是否可行?我找不到办法.

wpf colors skinning resourcedictionary

43
推荐指数
3
解决办法
5万
查看次数

标签 统计

colors ×1

resourcedictionary ×1

skinning ×1

wpf ×1