【发布时间】:2016-05-24 15:18:30
【问题描述】:
我有一个充满标签的网格,它们都使用相同的样式,即 DynamicResource:
<Label Grid.Row="0" Style="{DynamicResource MyStyle}"/>
<Label Grid.Row="1" Style="{DynamicResource MyStyle}"/>
<Label Grid.Row="2" Style="{DynamicResource MyStyle}"/>
有没有办法只为网格中的所有标签设置一次样式?我试过this way,但是BasedOn 不适用于DynamicResources。
【问题讨论】:
-
在您的
UC或Window中包含字典,然后将其称为StaticResource,或者像<Style TargetType="{x:Type Label}">..code</Style>那样设置标签的样式。 -
@XAMlMAX:您的意思是我的 App.xaml 中的 MergedDictionary?我如何把它放在我的 UC 中?
标签: c# wpf styling dynamicresource