WP71 MVVMLight 事件触发器无法识别

发布于 2024-11-09 14:03:03 字数 712 浏览 0 评论 0原文

遵循 Laurent 的升级指南 http://www.galasoft.ch/mvvm/installing/mangobeta/< /a> 从现有的 MVVMLight WP7 项目转到 WP71 项目。我已经正确更改了引用和命名空间。但 XAML 中无法识别 EventTrigger

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    <i:Interaction.Triggers>

        <i:EventTrigger EventName="Loaded">
            <cmd:EventToCommand 
                Command="{Binding Mode=OneWay, Path=LoadedCommand}"
                 PassEventArgsToCommand="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

我在 EventTrigger 元素上收到错误。

改变了吗?

Having followed Laurent's upgrade guide http://www.galasoft.ch/mvvm/installing/mangobeta/ to get from an existing MVVMLight WP7 project to a WP71 project. I have changed the references and namespaces corectly. But the EventTrigger is not recognised in the XAML

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    <i:Interaction.Triggers>

        <i:EventTrigger EventName="Loaded">
            <cmd:EventToCommand 
                Command="{Binding Mode=OneWay, Path=LoadedCommand}"
                 PassEventArgsToCommand="True" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

I get an error on the EventTrigger element.

Has it changed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

再见回来 2024-11-16 14:03:03

当我将应用程序从 WP7 升级到 WP7.1(Mango) 时,我遇到了完全相同的问题。问题出在 MVVM Light 二进制文件上。您需要升级到 WP7.1 二进制文件。

Laurent Bugnion ( https://stackoverflow.com/users/12233/lbugnion ) 解释了如何升级 MVVM Light 二进制文件他的网站在这里: http://www.galasoft.ch/mvvm/installing/mangobeta/< /a>

这些是我用来解决问题的基本步骤:

  • 下载最新的从此处下载最新版本

  • 打开并编译 WP71 项目。

  • 将二进制文件复制到您的 MVVM 二进制位置(在我的例子中为 C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries)

  • 打开您的项目

  • 在 References 文件夹中,删除 GalaSoft.MvvmLight、GalaSoft.MvvmLight.Extras 和 System .Windows.Interactivity。

  • 从文件夹 C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP71 添加新引用。

I had this exact same problem when I upgrade my application from WP7 to WP7.1(Mango). The problem was the MVVM Light Binaries. You need to upgrade to the WP7.1 Binaries.

Laurent Bugnion ( https://stackoverflow.com/users/12233/lbugnion ) explains how to upgrade the MVVM Light binaries on his website here: http://www.galasoft.ch/mvvm/installing/mangobeta/

These are the essential steps I used to fix my problem:

  • Download the most recent version from here.

  • Open and Compile the WP71 project.

  • Copy the binaries to your MVVM Binary location (in my case C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries)

  • Open your project

  • In the References folder, delete GalaSoft.MvvmLight, GalaSoft.MvvmLight.Extras and System.Windows.Interactivity.

  • Add the new references from the folder C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP71.

没有伤那来痛 2024-11-16 14:03:03

升级到 Mango 后我也遇到了类似的问题。就我而言,我在 MenuItem 单击上绑定了 EventToCommand,但您似乎将其绑定在某种加载事件上。您可以尝试在从视图的代码隐藏加载的 evcent 中使用匿名委托。即:

this.Loaded+=(s,e)=>ViewModel.LoadedCommand.Execute(null);

就我而言,我从: 更改

<tk:MenuItem Header="Delete Snapshot" >
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click">
            <mvvmLight:EventToCommand Command="{Binding DeleteSnapshotCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem,ElementName=lstSnapshots}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</tk:MenuItem>

<tk:MenuItem Header="Delete Snapshot" Command="{Binding DeleteSnapshotCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem,ElementName=lstSnapshots}" />

I had a similar problem after upgrading to Mango. In my case, I had the EventToCommand binding on a MenuItem click, but you seem to have it on some sort of loaded event. You could try using an anonymous delegate in the loaded evcent from the view's code-bhind. Ie:

this.Loaded+=(s,e)=>ViewModel.LoadedCommand.Execute(null);

In my case, I changed from:

<tk:MenuItem Header="Delete Snapshot" >
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Click">
            <mvvmLight:EventToCommand Command="{Binding DeleteSnapshotCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem,ElementName=lstSnapshots}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
</tk:MenuItem>

to

<tk:MenuItem Header="Delete Snapshot" Command="{Binding DeleteSnapshotCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem,ElementName=lstSnapshots}" />
踏雪无痕 2024-11-16 14:03:03

我已经解决了这个问题,恢复到了芒果之前的开发环境。
这不是我想要的解决方案,但是 - 不断前进。

I have moved on from this issue, by reverting back to pre-mango dev environment.
Not the solution I wanted, but - onwards and forwards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文