There are two properties of same type but exists in different classes.
有两个相同类型的属性,但存在于不同的类中。
- FrameworkElement.Triggers Property
- FrameworkElement.Triggers属性
- Style.Triggers Property
- Style.Triggers属性
This confuses me a lot, and so I've few questions whose answer I'm looking for:
这让我很困惑,所以我几乎没有问题,我正在寻找的答案:
- Why two properties of same type exist?
- 为什么存在两种相同类型的属性?
- When should I use what?
- 我什么时候应该用什么?
- What one can do that other cannot?
- 其他人不能做什么?
1 个解决方案
#1
5
As the documentation page that you've linked to in the question says:
正如您在问题中链接到的文档页面所示:
FrameworkElement.Triggers can only contain EventTriggers and is not usually used. You cannot define (Property based) Triggers or (data-bound value based) DataTriggers with this method.
FrameworkElement.Triggers只能包含EventTriggers,通常不会使用。您不能使用此方法定义(基于属性)触发器或(基于数据绑定值)DataTriggers。
For most practical purposes, you should be using Style.Triggers or DataTemplate.Triggers or ControlTemplate.Triggers. (Sorry for adding to the confusion).
对于大多数实际用途,您应该使用Style.Triggers或DataTemplate.Triggers或ControlTemplate.Triggers。 (很抱歉增加了混乱)。
#1
5
As the documentation page that you've linked to in the question says:
正如您在问题中链接到的文档页面所示:
FrameworkElement.Triggers can only contain EventTriggers and is not usually used. You cannot define (Property based) Triggers or (data-bound value based) DataTriggers with this method.
FrameworkElement.Triggers只能包含EventTriggers,通常不会使用。您不能使用此方法定义(基于属性)触发器或(基于数据绑定值)DataTriggers。
For most practical purposes, you should be using Style.Triggers or DataTemplate.Triggers or ControlTemplate.Triggers. (Sorry for adding to the confusion).
对于大多数实际用途,您应该使用Style.Triggers或DataTemplate.Triggers或ControlTemplate.Triggers。 (很抱歉增加了混乱)。