您可以使用{} ThemeResource标记扩展来实现你想要做什么。 在你的Page.xaml:
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary Source="Dictionary2.xaml" x:Key="Dark"/>
<ResourceDictionary Source="Dictionary1.xaml" x:Key="Light"/>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Page.Resources>
<StackPanel>
<TextBlock Text="{ThemeResource txt}"/>
</StackPanel>
Dictionary1.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Styles">
<x:String x:Key="txt">Light</x:String>
</ResourceDictionary>
Dictionary2.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Styles">
<x:String x:Key="txt">Dark</x:String>
</ResourceDictionary>
你想TextBlock的文本设置为亮/暗或这个问题的答案? – AVK
@AVKNaidu是例如 –
您可以显示完整的代码,了解如何将文本设置为文本块? – AVK