我所看到的大多數WPF樣式被拆分成一個非常長的Theme.xaml文件。我想我的分手是爲了便於閱讀,所以我Theme.xaml看起來是這樣的:拆分WPF樣式XAML文件
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;v3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml"/>
<ResourceDictionary Source="Controls/Brushes.xaml"/>
<ResourceDictionary Source="Controls/Buttons.xaml"/>
...
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
的問題是,這種解決方案是行不通的。我有一個默認的按鈕樣式是支持算法FMP一個按鈕的默認Aero的風格:
<Style x:Key="{x:Type Button}" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="FontSize" Value="14"/>
...
</Style>
如果我把所有這一切都在一個文件中,但一旦工程,我把它分解了,我得到的StackOverflow例外,因爲它認爲它是BasedOn本身。有沒有解決的辦法?在合併資源字典時,WPF如何添加資源?
我自己的自定義按鈕樣式適用於任何地方,我不希望每次創建按鈕時都必須明確設置按鈕樣式。我只想調整PresentationFramework.Aero中現有的默認按鈕樣式 – anon 2010-03-12 17:30:00