How do you escape parentheses in a Binding indexer
I have the following XAML:
<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource MyDataKey}}">
<TextBox Name="_myId" Text="{Binding MyDictionary[(Textbox.Name)]}" />
</Grid>
But it thinks the key in my dictionary is called "(Textbox.Name)", instead of "_m开发者_高级运维yId". The format below works, where I have a property in my class called "_myId":
<TextBox Name="_myId" Text="{Binding (Textbox.Name)}" />
I've tried using ^ and \ to escape the brackets. Is this syntax supported? I'm trying to avoid duplication of the name in two attributes.
You can not have references to other instances in indexers in XAML binding expressions. You can only have acutal literals such as Text="{Binding MyDictionary[somename]"}
, wich is the c# equivalent to myDictionary["somename"]
.
精彩评论