Reputation: 10969
I want to bind to a value in a dictionary property of an object. The dictionary key of this value is a string ending in '{'. How do I express this in XAML?
I presumably need to escape this character somehow.
Example XAML that doesn't work:
<TextBlock Text="{Binding Attribs[test{]}" />
Here Attribs
is a property on the datacontext object of type IDictionary<string, object>
Upvotes: 1
Views: 132
Reputation:
I just have tested the following XAML fragment, and it seems to work fine:
<TextBlock Text="{Binding Attribs[test\{]}"/>
The \ escape character is explained in this article.
Upvotes: 0
Reputation: 10969
This XAML works, by avoiding using a binding expression and instead using a Binding element:
<TextBlock>
<TextBlock.Text><Binding Path="Attribs[test{]"/></TextBlock.Text>
</TextBlock>
Upvotes: 2