我正在尝试在WPF和Silverlight中实现这篇文章中的样式绑定。
我有一个资源字典generic.Xaml,其中包含以下代码:
我需要获取ThemeProvider的实例,以更新在Generic.xaml中绑定的颜色/画刷。是否可以获取键为“ThemeProvider”的资源实例,以便我可以更新它?
如果您知道一个跨平台的WPF和Silverlight实现,将获得额外的信用分!
注意:我需要在声明Generic.xaml的程序集之外获取它。
我有一个资源字典generic.Xaml,其中包含以下代码:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AComponent;component/Themes/MyCustomStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
MyCustomStyles.xaml文件的开头如下所示
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<t:ThemeColorProvider x:Key="ThemeProvider"/>
我需要获取ThemeProvider的实例,以更新在Generic.xaml中绑定的颜色/画刷。是否可以获取键为“ThemeProvider”的资源实例,以便我可以更新它?
如果您知道一个跨平台的WPF和Silverlight实现,将获得额外的信用分!
注意:我需要在声明Generic.xaml的程序集之外获取它。
FindResource
方法怎么样? - Hossein Narimani Rad