【问题标题】:How to bind view's loaded event to a method in the view model in WP7.1如何将视图的加载事件绑定到 WP7.1 中视图模型中的方法
【发布时间】:2012-01-05 05:27:49
【问题描述】:

我想在视图模型中处理我的视图 (PhoneApplicationPage) 的 Page_Loaded 事件。这曾经是通过以下方式完成的:

<i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <Command:EventToCommand Command="{Binding LoadedCommand}" />
        </i:EventTrigger>
</i:Interaction.Triggers>

此方法使用 MVVM Light EventToCommand

但他的方法不再有效并给出以下错误:

“EventToCommand”类型的值不能添加到集合中,或者 'TriggerActionCollection' 类型的字典。

在 WP7.1 中,将视图事件绑定到视图模型方法的正确 MVVM 方法是什么?

【问题讨论】:

    标签: .net silverlight mvvm command windows-phone-7.1


    【解决方案1】:

    尝试使用InvokeCommandAction

    更新

    其实如果你只是想让它直接绑定到方法上你也可以试试CallMethodAction。 ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      • 1970-01-01
      • 1970-01-01
      • 2016-08-02
      相关资源
      最近更新 更多