1 依据博文-类库无法添加wpf资源字典来设置类库工程项目
2.再类库中添加资源字典
3.再资源字典中添加下面资源
<ImageBrush x:Key="myImageBrush" ImageSource="img12.jpg" Viewport="0 0 32 32"
ViewportUnits="Absolute" TileMode="None"></ImageBrush>
4 在wpf项目中添加类库的引用
5.在窗体加载事件中添加如下代码即可
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ResourceDictionary dictionary = new ResourceDictionary();
dictionary.Source = new Uri("ImageLibrary;component/Dictionary.xaml", UriKind.Relative);
btn.Background = (Brush)dictionary["myImageBrush"];
}