简体   繁体   中英

XAML bind to a property with @

i Have a class which has a @base property. The @ is required because "base" is a reserved word of the C# language.

How do i bind from XAML to this property?

base is a keyword in C# but not in XAML, therefore you can simply write...

<TextBlock Text="{Binding base}" />

if you have something like this in the current DataContext:

public string @base { get { return "Hello, World!"; } }

Keep in mind that @ is not part of the property name in C#, it just means the following token is an identifier . The real property name is base even though you have to refer to it as @base in C#.

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