在Canvas Windows 10 Universal Apps上绘制形状时出错

时间:2016-10-19 11:01:18

标签: c# xaml uwp windows-8.1-universal

我正在创建一个在画布上绘制形状的应用程序,这些形状被识别为使用https://github.com/phatware/WritePadSDK sdk作为书写板的字母。但问题是这个api代码在Windows 8.1项目中使用时工作正常但是当在Windows 10通用应用程序中使用相同的代码时,它会在我调试代码时产生错误。 xaml代码如下所示

     <Canvas   Background="WhiteSmoke" Name="InkCanvas" PointerPressed="OnCanvasPointerPressed"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" PointerReleased="OnCanvasPointerReleased" PointerCaptureLost="OnCanvasPointerCaptureLost" PointerExited="InkCanvas_OnPointerExited" PointerMoved="OnCanvasPointerMoved" LostFocus="InkCanvas_LostFocus">

并且使用sdk识别形状的代码在下面给出,它在Canvas的PointerReleased事件上执行: -

 var resultValue = recognizerShared.RecognizeStrokes(InkCanvas.Children.ToList(), false);

当我检查sdk中给出的方法,即 RecognizeStrokes 进行重新定位时,我在调试时遇到错误

enter image description here

由于此代码在Windows 8.1项目中正常工作,我认为它可能是Windows 10通用应用程序问题的待办事项

Excelption详细信息如下: -

AccessKey = 'new System.Collections.Generic.Mscorlib_CollectionDebugView<Windows.UI.Xaml.UIElement>(strokes).Items[0].AccessKey' threw an exception of type 'System.InvalidCastException'

AccessKeyScopeOwner ='new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0] .AccessKeyScopeOwner'抛出类型'System.InvalidCastException'的异常

AllowFocusOnInteraction ='((Windows.UI.Xaml.FrameworkElement)new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0])。AllowFocusOnInteraction'抛出类型'System.InvalidCastException'的异常

AllowFocusWhenDisabled ='((Windows.UI.Xaml.FrameworkElement)new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0])。AllowFocusWhenDisabled'抛出类型'System.InvalidCastException'的异常

ContextFlyout ='new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0] .ContextFlyout'抛出类型'System.InvalidCastException'的异常

ExitDisplayModeOnAccessKeyInvoked ='new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0] .ExitDisplayModeOnAccessKeyInvoked'抛出类型'System.InvalidCastException'的异常

FocusVisualMargin ='((Windows.UI.Xaml.FrameworkElement)new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0])。FocusVisualMargin'引发了'System.InvalidCastException'类型的异常

FocusVisualPrimaryBrush ='((Windows.UI.Xaml.FrameworkElement)new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0])。FocusVisualPrimaryBrush'引发了'System.InvalidCastException'类型的异常

new System.Collections.Generic.Mscorlib_CollectionDebugView(strokes).Items [0] .IsAccessKeyScope

请帮我解决上面的问题。

下载示例项目代码的链接如下所示,用于测试可以看到问题的位置

https://www.dropbox.com/s/1xbtxbxwyoyuf00/WindowsSDK.rar?dl=0

谢谢!

0 个答案:

没有答案