Andrew
Andrew

Reputation: 291

Nested curly brackets {{ }} in WPF/XAML

What is the meaning of nested curly brackets in attribute values in WPF/XAML markup? As in the following example:

 <ListBox ItemsSource="{Binding Source={StaticResource pictures}}">

Upvotes: 0

Views: 990

Answers (2)

Kishore Kumar
Kishore Kumar

Reputation: 21873

Nesting of multiple markup extensions is supported by WPF, and each markup extension will be evaluated deepest first.

 <Setter Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />

In this usage, the x:Static statement is evaluated first and returns a string. That string is then used as the argument for DynamicResource.

so here

<ListBox ItemsSource="{Binding Source={StaticResource pictures}}">

it will assign the pictures (may be collection) to the itemsource of the listbox

please have look at this http://msdn.microsoft.com/en-us/library/ms747254.aspx#Nesting

Upvotes: 1

BoltClock
BoltClock

Reputation: 724182

That binds the ItemsSource of the list box to a StaticResource called pictures. It's simply nesting one markup extension in another.

Read about markup extensions in XAML here: http://msdn.microsoft.com/en-us/library/ms747254.aspx

Upvotes: 2

Related Questions