This XAML source:
<TextBlock Margin="10,0,0,0" FontSize="16" />
is compiled to BAML, according to ILSpy:
<TextBlock Margin="10,0,0,0" TextBlock.FontSize="16" />
I may be wrong but it seems the BAML version uses the attached property syntax instead of the property syntax (used for example for Margin
).
I found:
- This related question How is the attached property TextBlock.FontSize used? says:
TextBlock.FontSize
is not an attached property, it's just a regular dependency property
which may be somehow contradictory with MSDN:
This dependency property also has an attached property usage. In XAML, the usage is <object TextBlock.FontSize="value".../>, where object is an object element (typically a flow element) contained within a TextBlock [...]
What is the correct explanation for this syntax difference between Margin
and FontSize
assignments in BAML?
Take a look at the reference source. There is:
with
TextElement.FontSizeProperty
defined like this:So while
FontSize
is not supposed to be used as an attached property, its identifier field is initialized by callingAddOwner
on the identifier field of an attached property.Just my guess, but I think that from this aspect
TextBlock.FontSize
is treated as an attached property.