2015-10-20 40 views
3

我有这样的Brushes.xaml:是否有一种方法可以使DynamicResource在ResourceDictionary中对于Freezable是动态的?

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:controls="clr-namespace:SkinBox.Controls"> 
    <SolidColorBrush x:Key="{x:Static controls:Keys.BackgroundBrushKey}" 
        Color="{DynamicResource {x:Static controls:Keys.BackgroundColorKey}}" /> 
</ResourceDictionary> 

而且在Generic.xaml这样使用它:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:SkinBox.Controls" 
        xmlns:system="clr-namespace:System;assembly=System"> 
    <ResourceDictionary.MergedDictionaries> 
     <ResourceDictionary Source="pack://application:,,,/SkinBox.Controls;component/Themes/Skins/Blue.xaml" /> 
     <ResourceDictionary Source="pack://application:,,,/SkinBox.Controls;component/Themes/Brushes.xaml" /> 
    </ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 

的问题是,WPF冻结刷所以DynamicResource没有效果。

有没有一个干净的方法来解决这个问题?我只能想到讨厌的黑客。

回答

0

思想的一种解决方法:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:controls="clr-namespace:SkinBox.Controls"> 
    <ResourceDictionary.MergedDictionaries> 
     <ResourceDictionary Source="pack://application:,,,/SkinBox.Controls;component/Themes/Skins/Yellow.Colors.xaml" /> 
     <ResourceDictionary Source="pack://application:,,,/SkinBox.Controls;component/Themes/Brushes.xaml" /> 
    </ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 

这仍然没有给出真正的动态资源,但让他们更新应用皮肤,当它重新应用刷子。

无需在每张皮肤上复制刷子。

相关问题