简体   繁体   中英

Xaml- Escape '@' in binding path

My binding is like this:

<... SelectedItem={Binding ElementName=NAME, Path=MyProperty.@enum} />

The @enum is inner property and the @ is part of it's name.

The error I get is

Unexpected token

how can I escape the @?

The @ character is used to escape an identifier name that would otherwise be recognized as C# keyword. Since enum is a keyword in C#, you'll have to escape it, but that applies only to C#. The property name is still enum .

So the corrent property path is also MyProperty.enum :

SelectedItem="{Binding ElementName=NAME, Path=MyProperty.enum}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM