开发中代码写法备忘
WPF后台代码调用资源字典
1 public static Style GetResource(string uri, string key) 2 { 3 foreach (ResourceDictionary rd in Application.Current.Resources.MergedDictionaries) 4 { 5 if (rd.Source == new Uri(uri, UriKind.RelativeOrAbsolute)) 6 return rd[key] as Style; 7 } 8 return null; 9 }
引用代码:
1 rb.Style = ResourceHelper.GetResource("Resources/ButtonStyle.xaml", "btnStyle1");