winrt xaml merged resources

后端 未结 1 936
旧时难觅i
旧时难觅i 2021-01-06 13:51

I need to separate application styles to several xaml files. But I also need to define some shared values like

100<         


        
相关标签:
1条回答
  • 2021-01-06 14:09

    Using merged dictionaries can get a bit tricky if you have dependencies between other merged dictionaries.

    When you have multiple application-scope resources the order of the declare is important. They are resolved in the inverse order of the declare, so in your case you should have the order.

    <Application.Resources>
    <ResourceDictionary >
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Styles1.xaml"/>
            <ResourceDictionary Source="Styles2.xaml"/>
            <ResourceDictionary Source="DefinedValues.xaml"/>
    
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
    

    Also, you may need to reference the other ResourceDictionary in Styles1.xaml. This worked for me in Styles1.xaml.

    <ResourceDictionary "...">
    
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="SharedValues.xaml" />
      </ResourceDictionary.MergedDictionaries>
    
      <Style x:Name="AnotherStyle"
             TargetType="Button">
        <Setter Property="Height"
                Value="{StaticResource SharedValue}" />
      </Style>
    </ResourceDictionary>
    
    0 讨论(0)
提交回复
热议问题