开发者

Binding to a member function which takes no parameters?

开发者 https://www.devze.com 2023-02-19 15:00 出处:网络
In WPF VS2010, is it possible to bind to a member function which takes no parameters? In particular I\'d 开发者_如何学运维like to call my object\'s .ToString() method.

In WPF VS2010, is it possible to bind to a member function which takes no parameters?

In particular I'd 开发者_如何学运维like to call my object's .ToString() method.

I don't see why it's not possible, but I can't get it to work. It seems silly and pollutes my code to add a property that simply calls ToString.


<ObjectDataProvider x:Key="myKey" d:IsDataSource="True" ObjectType="{x:Type MyNameSpace:MyClass}" MethodName="ToString"/>

and

<TextBlock Text="{Binding Source={StaticResource myKey}}" />
0

精彩评论

暂无评论...
验证码 换一张
取 消