This has been bugging me for a long time now and I can't seem to find a good explanation for it. What is the purpose of the round brackets in this markup? Is it a XAML shortcut for casting? Why does it only seem to be used for animations?
Storyboard.TargetProperty="(TextBlock.RenderTransform).(RotateTransform.Angle)"
This is syntax for specifying a Type qualified DependencyProperty
. It is required, because the Storyboard.TargetProperty
attached property can be attached to any DependencyObject
. That means the XAML parser won't know how to resolve the properties unless they are fully qualified.
This syntax is also used for things like binding to attached properties. Here is a contrived example to demonstrate this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="Foo" Background="Blue" Grid.Row="10" />
<Border x:Name="Bar" Background="Red" Height="{Binding (Grid.Row), ElementName=Foo}" />
</Grid>
If you remove the parenthesis from the Binding
, you'll get a binding error (because there is no Grid property on the Border
element).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With