Nested curly brackets {{ }} in WPF/XAML
What is the meaning of nested curly brackets in attribute values in WPF/XAML markup? As in the foll开发者_如何学Cowing example:
<ListBox ItemsSource="{Binding Source={StaticResource pictures}}">
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
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
精彩评论