WP8.1(Silverlight)中交互触发器的XAML解析错误

9

我有一个适用于WP8.0的工作解决方案。但是我需要升级才能访问WNS。我已成功将WNS添加到升级解决方案中,主菜单可以正常运行。但是在升级到wp8.1(银光)后,我遇到了一些奇怪的错误,只出现在运行时。例如,它发生在以下用户控件中:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"
xmlns:View="clr-namespace:ShieldGenerator.View"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
x:Class="ShieldGenerator.View.MoveableShieldGear"
mc:Ignorable="d"
Canvas.Left="{Binding Gear.x}" Canvas.Top="{Binding Gear.y}" Canvas.ZIndex="{Binding Gear.z}" >

<Path Data="{Binding Gear.Path}" Fill="{Binding Gear.Color}" Stretch="Fill" UseLayoutRounding="False" Height="{Binding Gear.Height}" Width="{Binding Gear.Width}" Opacity="{Binding Gear.Opacity}">
    <Path.RenderTransform>
        <TransformGroup>
            <ScaleTransform ScaleX="{Binding Gear.Scale}" ScaleY="{Binding Gear.Scale}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}"/>
            <RotateTransform Angle="{Binding Gear.Rotate}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}" />
            <SkewTransform AngleX="{Binding Gear.SkewX}" AngleY="{Binding Gear.SkewY}" CenterX="{Binding Gear.CenterX}" CenterY="{Binding Gear.CenterY}" />
        </TransformGroup>
    </Path.RenderTransform>

    <i:Interaction.Triggers>

        <i:EventTrigger EventName="ManipulationStarted">
            <cmd:EventToCommand Command="{Binding MouseDownGearCommand}" PassEventArgsToCommand="True"/>
        </i:EventTrigger>

        <i:EventTrigger  EventName="ManipulationDelta">
            <cmd:EventToCommand Command="{Binding MouseGearMoveCommand, Mode=OneWay}" PassEventArgsToCommand="True"/>
        </i:EventTrigger>

        <i:EventTrigger  EventName="ManipulationCompleted">
            <cmd:EventToCommand Command="{Binding MouseUpGearCommand}" PassEventArgsToCommand="True"/>
        </i:EventTrigger>

        <i:EventTrigger  EventName="DoubleTap">
            <cmd:EventToCommand Command="{Binding DoubleTapCommand}" PassEventArgsToCommand="True"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>

</Path>

</UserControl>

当事件绑定到我的VM时,VM中的命令被定义为RelayCommand。如上所述,这是一个无错误的工作解决方案。我进行了更新,编译时仍然没有错误。 在视图背后没有代码,但错误发生在下面标有ERROR的行(在*.g.cs文件中)。

namespace ShieldGenerator.View {


public partial class MoveableShieldGear : System.Windows.Controls.UserControl {

    private bool _contentLoaded;

    /// <summary>
    /// InitializeComponent
    /// </summary>
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public void InitializeComponent() {
        if (_contentLoaded) {
            return;
        }
        _contentLoaded = true;
        System.Windows.Application.LoadComponent(this, new System.Uri("/ShieldGenerator;component/View/MoveableShieldGear.xaml", System.UriKind.Relative)); //ERROR
    }
}
}

该错误指的是上面xaml代码中的<i:Interaction.Triggers>这行。
我已经尝试卸载和安装了几个包,但没有成功。我试图搜索并找到包含Mode=Oneway的想法,并有些人声称在xaml解析器中出现错误。但我完全不知道该怎么办。
希望有人能帮忙! 该错误enter image description here 每当我使用i:interaction时,都会显示此错误。我一直在寻找一种方法来找到System.Windows.Interactivity的wp8.1版本,但一直无法找到。因此,我确保MVVMLight工具已更新: enter image description here 基于评论的信息 新的app.config有所不同
是一个新添加。
新的WMAppManifest.xml中的差异 NotificationService="WNS"因为我已经设置好了并且它可以正常工作。
<Capabilities>
  <Capability Name="ID_CAP_NETWORKING" />
  <Capability Name="ID_CAP_MEDIALIB_AUDIO" />
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> 
  <Capability Name="ID_CAP_MEDIALIB_PHOTO" />
</Capabilities>

旧版

<Capabilities>
  <Capability Name="ID_CAP_NETWORKING" />
  <Capability Name="ID_CAP_MEDIALIB_AUDIO" />
  <Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
  <Capability Name="ID_CAP_SENSORS" />
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
  <Capability Name="ID_CAP_MEDIALIB_PHOTO" />
  <Capability Name="ID_CAP_PUSH_NOTIFICATION" />
  <Capability Name="ID_CAP_IDENTITY_USER" />
 </Capabilities>

我已经移除了不再使用的功能,并在WP8.1中添加了新的Package.appxmanifest

<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="musicLibrary" />
<Capability Name="picturesLibrary" />

我在另一个问题中也遇到了AGHost.exe的问题,但我没有尝试删除它,因为我认为以下内容是必需的。

<Applications>
<Application Id="xd82c080dy903dy47f4yba02y5a36d745c72bx" Executable="AGHost.exe" EntryPoint="StartUp/FirstPage.xaml">
  <m3:VisualElements DisplayName="XXXXX" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="XXXX" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
    <m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
    </m3:DefaultTile>
    <m3:SplashScreen Image="Assets\Splashscreen.png" />
  </m3:VisualElements>
</Application>


</Applications>
<Capabilities>
    <Capability Name="internetClientServer" />
    <Capability Name="musicLibrary" />
    <Capability Name="picturesLibrary" />
</Capabilities>
<Extensions>
  <Extension Category="windows.activatableClass.inProcessServer">
    <InProcessServer>
      <Path>AgHostSvcs.dll</Path>
      <ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
    </InProcessServer>
  </Extension>
</Extensions>

无法在此文件中找到其他问题。AssemblyInfo.csAppManifest.xml是相同的。查看引用文件夹,引用似乎没问题,并且已经更新为wp8.1(能够更新的)。 额外信息 如果我将xaml代码(即带有交互的路径)复制到另一个工作的页面中,那么它会失败并显示相同的错误,在解析不包含该片段的页面的xaml时出现错误。 新更新 似乎在升级过程中,某些东西在解决方案和项目中被损坏了。我发现的是,我可以在新项目中让代码正常工作。如果我运行并部署该项目,则代码可以正常工作。
另一方面,如果我使用同样的项目,当从另一个项目导航到它时"/BC_Creator;component/MainPage.xaml",则会再次出现上述错误。我现在唯一的想法是尝试创建全新的项目并将代码复制粘贴到新文件中。因为导入它们似乎仍然无法工作。
这到底发生了什么:S

实际错误是什么? - Chris W.
@ChrisW. 添加了错误描述,第24个位置是在<i:Interaction.Triggers>这一行中的 .。由于升级后出现了另一个问题,我无法使用调试器提取错误消息。参考问题https://dev59.com/5F0Z5IYBdhLWcg3wdQEy - JTIM
嗯,好的...根据您的代码行数和异常中提到的System.Windows.ni.dll,我认为这可能与那些触发器或它们的交互/命名空间等无关。不过我想问一下,您是否可能在WMAppManifest.xaml之类的项目引用中丢失了一些需要手动添加的内容? - Chris W.
奇怪的是,当我将它们注释掉时,它就可以工作。但仍然存在慢响应的问题,就像我所提到的那个问题一样。现在已经很晚了,我会尝试明天进行比较。非常感谢您的建议! - JTIM
@ChrisW。我现在已经找不到任何错误了,所以我添加了很多信息 :/ 因为我有些迷茫。运行旧代码,即升级之前的代码,一切正常,我可以附加调试器来运行解决方案。:/ :S 但是我需要新的WNS通知,这就是为什么我升级的原因. . . - JTIM
@ChrisW。现在我再也没有调试器或模拟器启动的问题了。VS2013似乎正常工作。但是,在将项目导入新解决方案后,我仍然在同一位置收到错误信息。 我的唯一想法是创建一个新项目并导入视图和视图模型,以查看是否只有这个错误。因为在新解决方案中进行上述代码的简单测试运行良好。 - JTIM
1个回答

1

我仍然期待有答案。

但是,我的当前结果是MVVMLight包存在问题。

升级解决方案后,使用packmanager控制台进行卸载和重新安装,我已经删除了所有错误。但是解决方案仍未起作用。这导致我不得不创建一个新的解决方案并导入旧项目。然而,一些问题仍然存在,导致将内容复制到具有相同名称的新文件中。突然间它奏效了,真是很奇怪 :/

旧解决方案仍然无法工作,即使测试导入旧文件(不是项目,只是代码文件)也不起作用,只有重新创建和复制才能奏效。

这真的很奇怪,所以仍然期待解决方案,因为这需要很长时间!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接