views:

70

answers:

1

XAML: What is the functional difference between the following notations?

Is there any reason I shouldn't use the first method for properties?

<Setter Property="Shape.Stroke" TargetName="circle" Value="#FF3C7FB1"/>

<Setter Property="Shape.Stroke" TargetName="arrow">
  <Setter.Value>
    <SolidColorBrush>#FF222222</SolidColorBrush>
  </Setter.Value>
</Setter>

So I remember to add tags after reputation is high enough:

Tag: Expanded

EDIT 0: I am using the default templates to create custom controls and noticed the latter layout is how Microsoft does it. Is this to expedite parsing or simply by convention?

EDIT 1: I gather that the converters are brought into service when using the former notation, so I guess my question becomes: Is it a performance concern and, if so, are there any benchmarks?

+2  A: 

Those are equivalent notations really. The first one is shorter, because WPF uses a value converter implicitly to convert the given string. The second one is explicit, more flexible, more verbose, but could be the best choice in case if you need to set a complex value, that you also define in XAML.

Shouldn't be a performance concern, unless you're calling the setter million times a second.

Yacoder
Thanks Yacoder. So if I see it in MS styles, it should be by convention and the fact that it doubles/triples the loc is not a concern? TIA
Brad
Well, maybe that XAML was generated by a tool, like Expression.
Yacoder
Makes sense, thanks for taking the time.
Brad