JTI*_*TIM 9 c# silverlight xaml mvvm-light windows-phone-8.1
我有一个WP8.0的工作解决方案.但我需要升级才能访问WNS.我已成功将WNS添加到主菜单中的升级解决方案中.但在升级到wp8.1(silverlight)之后,我遇到了一些奇怪的错误,这只发生在运行时.作为示例,它发生在以下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>
Run Code Online (Sandbox Code Playgroud)
如果事件绑定到我的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
}
}
}
Run Code Online (Sandbox Code Playgroud)
该错误指的<i:Interaction.Triggers>是上述xaml代码中的行.
我尝试卸载并安装多个软件包但没有成功.我试图搜索,并找到包含的想法Mode=Oneway,并在xaml解析器中说明一些错误.我完全失去了.
希望有人可以帮忙!
错误
我使用的任何地方都会显示此错误i:interaction.我找了一种方法来找到一个wp8.1版本System.Windows.Interactivity但是还没有能够这样做.因此,我确保MVVMLight工具已更新:

基于评论的信息
新的差异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>
Run Code Online (Sandbox Code Playgroud)
旧
<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>
Run Code Online (Sandbox Code Playgroud)
我删除了我不再使用的功能.并添加到Package.appxmanifestWP8.1 的新版本中
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="musicLibrary" />
<Capability Name="picturesLibrary" />
Run Code Online (Sandbox Code Playgroud)
我有另一个问题也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>
Run Code Online (Sandbox Code Playgroud)
在此文件中找不到任何其他问题.
AssemblyInfo.cs并且AppManifest.xml是一样的.查看引用文件夹,引用似乎没问题,并针对wp8.1更新(可能的)
额外
如果我将xaml代码(即带有交互的路径)复制到另一个有效的页面中.然后,在没有代码片段的页面的xaml解析期间,它失败并出现相同的错误.
新的更新 似乎在升级后,解决方案和项目中的某些东西被破坏了.以下我发现,我可以获得代码并在新项目中工作.如果我运行和部署项目,代码可以工作.
另一方面,如果我使用相同的项目,在部署时工作,现在从另一个项目导航到它"/BC_Creator;component/MainPage.xaml"然后再次发生上述错误.我现在唯一的想法是尝试创建全新的项目并将代码复制粘贴到新文件中.由于导入它们似乎仍然不起作用.
WTF已经发生:S
我仍然愿意寻求答案。
但我目前的结果是,实际上 MVVMLight 包才是问题所在。
升级解决方案、使用 packmanager 控制台卸载并重新安装后,我删除了所有错误。但该解决方案不起作用。这最终导致我必须创建一个新的解决方案并导入旧项目。然而,一些问题仍然存在,导致复制粘贴到使用相同名称创建的新文件中。突然它起作用了,太奇怪了:/
旧的解决方案仍然不起作用,甚至测试导入旧文件(不是项目只是代码文件)也不起作用,只有重新创建和复制才有效。
这真的很奇怪,所以仍然愿意寻求解决方案,因为这将需要很长的时间!