简体   繁体   English

绑定到不带参数的成员函数?

[英]Binding to a member function which takes no parameters?

In WPF VS2010, is it possible to bind to a member function which takes no parameters? 在WPF VS2010中,是否可以绑定到不带参数的成员函数?

In particular I'd like to call my object's .ToString() method. 特别是我想调用我的对象的.ToString()方法。

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. 看起来很愚蠢并且污染我的代码来添加一个简单地调用ToString的属性。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将对象和成员名称作为参数的泛型函数? - Generic function that takes an object and a member name as parameters? 如何制作一个遍历列表并以要访问的数据成员作为输入参数的函数 - How can I make a function that loops over a list and takes which data member to access as input parameter 创建带有参数的委托函数 - Creating delegate function that takes parameters 以属性为参数的泛型函数 - Generic function that takes properties as parameters 将类添加到仅需要1个参数的方法中? - Adding class into method which only takes 1 parameters? 在接口中定义一个接受 n 个参数的方法 - Define a method in interface which takes n parameters 如何对具有相同成员的不同类型参数使用相同的函数? - How can I use the same function for different type parameters which have the same member? 如何使用带有构造函数参数的类注册依赖注入 - How to register a dependency injection with a class which takes constructor parameters 在Java中,什么类型表示带有3个参数的函数或lambda表达式? - In Java, what type represents a function or lambda expression that takes 3 parameters? Blazor:传递一个 function ,它将参数传递给组件并从中调用它 - Blazor: Pass a function that takes parameters to a component and call it from it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM