【发布时间】:2014-01-07 07:20:49
【问题描述】:
我的一个网格目前以以下代码开头:
<Grid x:Name="Top_GRID" Margin="4.953,10" Width="817.28">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="3"/>
<Setter Property="Background" Value="Red" />
</Style>
<Style TargetType="TextBox">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="3"/>
</Style>
<Style TargetType="Button">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="3"/>
</Style>
</Grid.Resources>
澄清一下 - 我想声明一个 Grid,其中所有 TextBlocks 的 Background 属性都设置为“Red”。所有 Button 边距都设置为“3”,依此类推。
我想将资源定义移动到字典文件中。
我应该以某种方式将其包装为 Style 吗?
如果是这样,我将有一个递归样式声明(我认为这是非法的)。
听起来很简单,但我找不到方法。
【问题讨论】:
标签: wpf resources resourcedictionary