【问题标题】:Silverlight. Cannot set base style from other xaml resources银光。无法从其他 xaml 资源设置基本样式
【发布时间】:2011-05-14 20:54:46
【问题描述】:

我需要基于 RedButtonStyle 创建名为 OkButtonStyle 的资源。 但我有没有找到异常的关键资源。我做错了什么? 我有两个资源字典。 RedButtonStyle 所在的 baseStyles.xaml 和我需要找到我的 okbuttonstyle 的 style.xaml 但我所有的努力都没有结果。

App.xaml

     <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="baseStyles.xaml" />
            <ResourceDictionary x:Name="currentTheme" Source="styles.xaml" />

        </ResourceDictionary.MergedDictionaries>

styles.xaml

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="baseStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="OkButtonStyle"
       BasedOn="RedButtonStyle"
       TargetType="Button">
</Style>

baseStyles.xaml

<Style x:Key="RedButtonStyle" TargetType="Button"> ...properties... </Style>

【问题讨论】:

    标签: c# .net wpf silverlight resources


    【解决方案1】:

    而不是使用语法:

    <Style BasedOn="RedButtonStyle" ...
    

    使用语法:

    <Style BasedOn="{StaticResource RedButtonStyle}" ...
    

    Style.BasedOn 属性不是它所基于的其他样式的名称,它它所基于的样式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 2017-08-24
      • 1970-01-01
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多