开发者

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

XAML: What is the functional diff开发者_如何学Cerence 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜