Kylo Ren
Kylo Ren

Reputation: 8823

StaticResource vs StaticResourceExtension syntax

What's the difference between.

<TextBox Text="{local:BindingResourceExtension MyBinding}" >
    <TextBox.Style>
        <StaticResourceExtension  ResourceKey="style" />
    </TextBox.Style>
</TextBox>

and

<TextBox Text="{local:BindingResourceExtension MyBinding}" Style="{StaticResource style}"/>

Which should be preferred in XAML?

Upvotes: 0

Views: 626

Answers (1)

BoltClock
BoltClock

Reputation: 723729

There is no difference. The curly brace syntax is designed specifically so you can use markup extensions within attribute values without having to resort to specifying the properties as child elements like in the first example. So, naturally, the curly brace syntax is preferred in those situations.

Upvotes: 1

Related Questions