Share wpf styles for more solution projects

first, you would have to create your styles in one (or more) RDs in your project "AppStyle". Let's assume there would be a file "stili.xaml" in that project's root folder, containing something along the lines of:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Style TargetType="Button">
   <!-- ... -->
  </Style>
</ResourceDictionary>

To use the above RD, you would then add a link to it in your other assemblies' App.xaml like so:

<Application.Resources>
  <!-- ... -->
  <ResourceDictionary>
   <ResourceDictionary.MergedDictionaries>
     <ResourceDictionary Source="pack://application:,,,/AppStyle;component/stili.xaml" />
   </ResourceDictionary.MergedDictionaries>
  </ResourceDictionary>
</Application.Resources>

posted on 2011-05-27 17:24  Y#  阅读(165)  评论(0编辑  收藏  举报

导航