我认为元素属性语法和属性属性语法没有太大的语义差异。但是,我发现一定有一些区别。元素属性语法和atrribute属性语法之间是否存在语义上的区别?
E.g.下面的例子只是演示了一个简单的触发器:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button><Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<TextBlock x:Name="hello" Text="Hello" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="Red" TargetName="hello"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template></Button>
</Page>
但是,如果我用一个元素属性的语法触发的财产Property
,它抛出一个异常说二传手! (不触发)需要属性和值。
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button><Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<TextBlock x:Name="hello" Text="Hello" />
<ControlTemplate.Triggers>
<Trigger Value="True">
<Trigger.Property>IsMouseOver</Trigger.Property>
<Setter Property="Foreground" Value="Red" TargetName="hello"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template></Button>
</Page>
那么,什么元素属性语法和属性属性语法之间的隐藏区别?