简体   繁体   English

交互时xaml解析错误触发wp8.1(silverlight)

[英]xaml parse error on interaction triggers wp8.1(silverlight)

I have a working solution for WP8.0. 我有一个WP8.0的工作解决方案。 But I needed to upgrade to get access to WNS. 但我需要升级才能访问WNS。 I have succeeded in adding WNS to the upgrade solution in the main menu works. 我已成功将WNS添加到主菜单中的升级解决方案中。 But after Upgrading to wp8.1(silverlight), I have had some weird errors, that only happens on runtime. 但在升级到wp8.1(silverlight)之后,我遇到了一些奇怪的错误,这只发生在运行时。 As an example it happens in the following usercontrol: 作为示例,它发生在以下usercontrol中:

<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>

Where the events are binded to my VM, the commands in the VM are defined as RelayCommand . 将事件绑定到我的VM的位置,VM中的命令被定义为RelayCommand As stated this was a working solution with no errors. 如上所述,这是一个没有错误的工作解决方案。 I updated and still no errors when compiling. 我在编译时更新了并且仍然没有错误。 I have no code behind the view, but the error occurs in the line below marked with ERROR (in the *.g.cs file) 我在视图后面没有代码,但错误发生在下面标有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
    }
}
}

The error refers to the line in <i:Interaction.Triggers> in the above xaml code. 该错误指的是上述xaml代码中<i:Interaction.Triggers>中的行。

I have tried uninstalling and installing several packages with no success. 我尝试卸载并安装多个软件包但没有成功。 I have tried to search around, and found ideas for including Mode=Oneway , and some stating error in the xaml parser. 我试图搜索,并找到包含Mode=Oneway想法,以及xaml解析器中的一些说明错误。 I am at a complete loss. 我完全失去了。

Hope somebody can help! 希望有人可以帮忙!

The error 错误 在此输入图像描述

This error is displayed everywhere I use i:interaction . 在我使用i:interaction任何地方都会显示此错误。 I have looked for a way to find an wp8.1 version of System.Windows.Interactivity But have not been able to do so. 我找了一种方法来找到一个wp8.1版本的System.Windows.Interactivity但是还没有能够这样做。 I have therefore made sure that the MVVMLight tools are updated: 因此,我确保MVVMLight工具已更新:

在此输入图像描述

Information based on the Comment 基于评论的信息

Difference in new app.config Is a new addition. app.config区别是新增加的。

Difference in new WMAppManifest.xml NotificationService="WNS" Because I have set it up and it works WMAppManifest.xml NotificationService =“WNS”因为我已经设置它并且它可以工作

NEW

<Capabilities>
  <Capability Name="ID_CAP_NETWORKING" />
  <Capability Name="ID_CAP_MEDIALIB_AUDIO" />
  <Capability Name="ID_CAP_WEBBROWSERCOMPONENT" /> 
  <Capability Name="ID_CAP_MEDIALIB_PHOTO" />
</Capabilities>

OLD

<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>

I have removed the capabilities I did not use anymore. 我删除了我不再使用的功能。 And added in the new Package.appxmanifest for WP8.1 并在WP8.1的新Package.appxmanifest中添加

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

I have per the other question also problem with the AGHost.exe, but I have not tried to delete it as I thought the below was mandatory. 我有另一个问题也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>

Cannot find any other issue in this file. 在此文件中找不到任何其他问题。 AssemblyInfo.cs and AppManifest.xml are the same. AssemblyInfo.csAppManifest.xml是一样的。 Looking at the reference folder the references seems okay, and are updated for wp8.1 (those that could) 查看引用文件夹,引用似乎没问题,并针对wp8.1更新(可能的)

Extra 额外

If I copy the xaml code (ie path with interaction) into another page that worked. 如果我将xaml代码(即带有交互的路径)复制到另一个有效的页面中。 Then it fails with the same error, during the xaml parsing for the page that worked without the snippet. 然后,在没有代码片段的页面的xaml解析期间,它失败并出现相同的错误。

New Update It seems that upon my upgrade something got damaged in the solutions and the projects. 新的更新似乎在升级后,解决方案和项目中的某些东西被破坏了。 The following I has found, is that I can get the code up and working in a new project. 以下我发现,我可以获得代码并在新项目中工作。 The code works if I run and deploy the project. 如果我运行和部署项目,代码可以工作。

If I on the other hand use the same project, that worked when deployed, now navigate to it from another project "/BC_Creator;component/MainPage.xaml" Then the above error occurs again. 另一方面,如果我在部署时使用相同的项目,现在从另一个项目"/BC_Creator;component/MainPage.xaml"导航到它,然后再次出现上述错误。 My only idea now is to try and create completely new projects and copy-pasting the code into new files. 我现在唯一的想法是尝试创建全新的项目并将代码复制粘贴到新文件中。 Since importing them still does not seem to work. 由于导入它们似乎仍然不起作用。

WTF has happend :S WTF已经发生:S

I am still open for answers. 我仍然愿意接受答案。

But my current result is that the it is in fact the MVVMLight package that is the issue. 但我目前的结果是它实际上是MVVMLight包是问题。

After upgrading the solutions, uninstalling and reinstalling using the packmanager console, I had removed all errors. 升级解决方案,使用packmanager控制台卸载并重新安装后,我删除了所有错误。 But the solution was not working. 但解决方案无效。 This has ended with me having to create a new solution and importing the old projects. 最后,我必须创建一个新的解决方案并导入旧项目。 Some of the issues however persisted, resulting in a copy-paster into new files, created with the same names. 然而,一些问题仍然存在,导致复制到新文件,使用相同的名称创建。 And suddenly it worked, so odd :/ 突然它起作用了,很奇怪:/

The old solution is still not working, and even testing to import the old files (not project JUST code files) did not work, only recreating and copying worked. 旧的解决方案仍然无法正常工作,甚至测试导入旧文件(不是项目JUST代码文件)也不起作用,只能重新创建和复制工作。

It is really odd, so still open for solutions, because this will take a looong time! 这真的很奇怪,所以仍然可以提供解决方案,因为这需要花费很长时间!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM