【问题标题】:How can I bind the result from methode in a static class with parameters (only XAML)如何将静态类中方法的结果与参数绑定(仅限 XAML)
【发布时间】:2009-07-30 14:49:07
【问题描述】:

我在静态类中有一个方法,这需要两个参数并返回一个字符串。

现在我应该从我的视图(没有 ViewModel)绑定这个结果。这可能吗?

伪代码:

xmlns:lang="clr-namespace:LanguageModule;assembly=LanguageModule"

<TextBlock Text="{x:Static lang:Translate[firstParameter, secondParameter]}"/>

【问题讨论】:

    标签: c# wpf xaml binding


    【解决方案1】:

    您可能想查看ObjectDataProvider

    使用 MethodName 属性调用 方法并使用 MethodParameters 属性传递参数 方法。然后,您可以绑定到 方法的结果。

    这里有一篇示例文章如何绑定到静态方法:

    http://www.thomasclaudiushuber.com/blog/2008/01/10/bind-to-methods-with-objectdataprovider/

    HTH

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-23
      • 2011-06-08
      • 2021-12-17
      • 1970-01-01
      • 2020-02-27
      • 2011-07-06
      • 1970-01-01
      • 2016-01-21
      相关资源
      最近更新 更多