2015-10-20 19 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> 

這仍然沒有給出真正的動態資源,但讓他們更新應用皮膚,當它重新應用刷子。

無需在每張皮膚上覆制刷子。

相關問題