47得票2回答
将样式的TargetType属性设置为基类

我在研究WPF时想让窗口上的所有元素共享相同的边距。我发现,所有能够拥有边距的控件都是从FrameworkElement派生的,因此我尝试了以下代码:<Window.Resources> <Style TargetType="{x:Type FrameworkElement}...

32得票5回答
在WPF中,我能否拥有一个样式同时适用于多个TargetType?

如标题所述,我的意思是像下面这样的东西:<Style TargetType="{x:Type TextBlock}" TargetType="{x:Type Label}" TargetType="{x:Type Button}" > 实际上我是为...

31得票5回答
何时使用{x:Type...}作为Style的TargetType?

这两者有什么区别:<Style TargetType="{x:Type Border}"> 并且:<Style TargetType="Border"> 何时以及为什么需要使用{x:Type ...}?

25得票3回答
TargetType="controlType"和TargetType="{x:Type controlType}"之间有什么区别?

在WPF中,您可以将TargetType设置为类型名称,也可以将其设置为{x:Type nameOfType}。有人知道它们之间的区别吗?

13得票1回答
x:Key 和 TargetType 在样式中的作用

使用以下语句是否有区别(或优势):Style x:Key="{x:Type DataGridCell}" TargetType="{x:Type DataGridCell}" 省略x:Key属性,是否可行? 我认为,在底层,WPF将键分配给相同的x:Type。

11得票3回答
WPF控件模板必须有TargetType吗?

WPF中的ControlTemplates是否需要TargetType?我正在重新设计一些控件,注意到ComboBoxItem、ListViewItem和ListBoxItem都有相同的模板: <ControlTemplate x:Key="ListBoxItemCT" Targe...