简体   繁体   中英

WPF and C# - Create x:static binding in code behind

Even if similar questions are already posted, I still haven't found a solution. In XAML I have this kind of "binding" that works good:

<Controls:MyCustomControl MyCustomAction="{x:Static staticTest:TestDelegate.myConverterAction}" [...]>

Now, I need to set the MyCustomAction property (that is a delegate property) in this way but via code. Is there a way to make a x:Static bind in XAML using C#?

The equivalent of you XAML in C# code would simply be:

MyCustomControl mcc = ...;

mcc.MyCustomAction = TestDelegate.myConverterAction;

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