【问题标题】:MVVMLight's EventToCommand in Xamarin.FormsXamarin.Forms 中的 MVVMLight 的 EventToCommand
【发布时间】:2016-06-01 17:49:27
【问题描述】:

我有可移植的 Xamarin.Forms 项目 - 4 个子项目:PCL 以及 iOS、WP 和 Droid。

我想在我的 PCL 项目(每个平台的共享 UI)中使用 Interaction.Triggers(来自 System.Windows.Interactivity - 确切地说来自 Blend SDK)和 EventToCommand(来自 MVVM Light)。有可能吗?

我知道 MVVM Light 是可移植的,但 System.Windows.Interactivity 不是,所以我有很大的问题。 如何在 Xamarin.Forms 中使用 EventToCommand?

【问题讨论】:

  • 这个问题你解决了吗?我在同一个搜索中,..NET 标准 2 使用 xamarin 表单,我正在尝试在我的 mvvm 中实现 ItemTp 事件,我正在使用 mvvmligh,但我找不到任何帮助

标签: c# wpf mvvm xamarin xamarin.forms


【解决方案1】:

在您的 Xamarin 项目中:

右键单击“引用”,“添加引用”。在 Assemblies -> Extensions 中有 System.Windows.Interactivity 可以检查和添加。

这就是全部:)

【讨论】:

    【解决方案2】:

    我是这样做的:

    首先我在页面中添加了命名空间

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:b="clr-namespace:Xamarin.Behaviors;assembly=Xamarin.Behaviors">
    

    然后我将行为添加到我的 ContentPage

    <b:Interaction.Behaviors>
      <b:BehaviorCollection>
        <b:EventToCommand EventName="Appearing" Command="{Binding InitializeViewModelCommand}" />
      </b:BehaviorCollection>
    </b:Interaction.Behaviors>
    

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-09
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-30
      • 1970-01-01
      相关资源
      最近更新 更多