I thought that element property syntax and attribute property syntax have no big semantical difference. However, I found that there must be some difference.
E.g. The following example just demonstrates a simple trigger:
<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>
However, if I used a element property syntax for property Property
of trigger, it throws an exception saying that setter! (not trigger) requires both property and value.
<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>
So, what is the hidden difference between element property syntax and attribute property syntax?