【发布时间】:2019-11-27 07:45:18
【问题描述】:
我在我的 wpf 中使用 Material Design。我在运行时更改主题(浅色/深色)。
<materialDesign:DialogHost Identifier="RootDialog">
<materialDesign:DialogHost.Resources>
<Style TargetType="materialDesign:Card" BasedOn="{StaticResource {x:Type materialDesign:Card}}">
<Style.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.dark.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Style.Resources>
<Setter Property="Background" Value="{DynamicResource MaterialDesignCardBackground}" />
</Style>
</materialDesign:DialogHost.Resources>
<Grid>
<!--some code-->
</Grid>
</materialDesign:DialogHost>
我想在运行时将资源字典的来源更改为
pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.light.xaml
我该怎么做?
【问题讨论】:
标签: wpf resources material-design runtime resourcedictionary