【问题标题】:How to force WPF UI element to use resources from the theme, ignoring app's resources如何强制 WPF UI 元素使用主题中的资源,而忽略应用程序的资源
【发布时间】:2010-01-26 21:45:47
【问题描述】:

有没有办法让 WPF 元素使用(显式或隐式)位于主题中的资源,即使 app.xaml 提供具有相同“键”-s 的资源?

我重新设计了所有默认控件的样式,并且所有这些样式都合并到了应用程序的ResourceDictionary。现在我有一个XAML 文件,它有一个元素,我想使用系统默认设置样式。有可能吗?

【问题讨论】:

    标签: wpf templates resources themes styles


    【解决方案1】:

    我找到了解决办法。

    我可以为资源中的单个元素应用系统主题,如下所示:

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>                
            <ResourceDictionary 
                Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component\themes/aero.normalcolor.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    

    【讨论】:

      猜你喜欢
      • 2017-12-03
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多