2
有沒有辦法在運行時替換WPF應用程序的所有畫筆定義,並且只聲明一次使用它的樣式?這對於不同的配色方案會很有用,但保留相同的用戶界面並聲明一次。我可以找到所有的例子在不同的主題文件中重複樣式 - 這是唯一的方法嗎?如何在WPF應用程序中應用不同的配色方案
小例子:
Blue.xaml
<SolidColorBrush x:Key="DefaultBackgroundBrush" Color="Blue"/>
Yellow.xaml
<SolidColorBrush x:Key="DefaultBackgroundBrush" Color="Yellow"/>
generic.xaml?
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource DefaultBackgroundBrush}" />
</Style>