我正在尝试实现WPF & Silverlight中本文中的样式绑定。
我有一个资源字典,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的程序集之外。
发布于 2015-03-23 14:19:30
如果您的资源是在generic.xaml中定义的,或者是在MergedDictionaries中在App.xaml中定义的任何资源,那么您需要使用Application.Current.Resources,例如:
(Color)Application.Current.Resources"ApplicationBarBackgroundColor“= BackgroundColor
发布于 2013-01-25 19:15:11
这可能有助于:
ThemeColorProvider value= (ThemeColorProvider)FindResource("ThemeProvider");
// update valuehttps://stackoverflow.com/questions/14528622
复制相似问题