2014-01-16 89 views
1

我正在構建一個WP8應用程序。在我的應用程序的初始頁面(登錄後),我使用GestureService來操縱屏幕並創建滑出菜單的效果。這是所有罰款,但問題是每當應用程序的任何其他頁面上ListPicker控制執行刷卡動作GestureService被激活,並引發了未處理的對象引用未設置例外,就像這樣:Windows Phone 8 - 應用程序崩潰時刷過Listpicker

enter image description here

我已經做了一些挖掘,這似乎是WP工具包中的一個錯誤。 WP8仿真器和我使用的諾基亞WP8開發手機的行爲是相同的。根據this線程,我可以使用ManipulationDelta和ManipulationCompleted事件來實現GestureListener所做的同樣的事情。所以我評論了GestureService代碼,並將操作事件添加到主頁上的網格中。低看,問題已經消失。

這裏是GestureService調用(我最初的XAML頁),這是現在註釋掉:

<toolkit:GestureService.GestureListener> 
      <toolkit:GestureListener DragDelta="GestureListener_OnDragDelta" DragCompleted="GestureListener_OnDragCompleted" /> 
     </toolkit:GestureService.GestureListener> 

我現在面臨被翻譯代碼到新格式的問題。下面是我使用(在VB)動作代碼:

If e.Direction = System.Windows.Controls.Orientation.Horizontal AndAlso e.HorizontalChange > 0 AndAlso Not _isSettingsOpen Then 
      Dim offset As Double = _feContainer.GetHorizontalOffset().Value + e.HorizontalChange 
      If offset > _dragDistanceToOpen Then 
       Me.OpenSettings() 
      Else 
       _feContainer.SetHorizontalOffset(offset) 
      End If 
     End If 

     If e.Direction = System.Windows.Controls.Orientation.Horizontal AndAlso e.HorizontalChange < 0 AndAlso _isSettingsOpen Then 
      Dim offsetContainer As Double = _feContainer.GetHorizontalOffset().Value + e.HorizontalChange 
      If offsetContainer < _dragDistanceToClose Then 
       Me.CloseSettings() 
      Else 
       _feContainer.SetHorizontalOffset(offsetContainer) 
      End If 
     End If 

不是在GestureListener所有屬性都可以/媲美的操作事件。所以我最好在士兵身上戰鬥並試圖重現操縱中的效果(如果甚至可能的話),還是有人知道這樣做的更好方法;即修復或繞過該錯誤以允許GestureService正常工作的方式......?

我已經嘗試添加GestureListener代碼並嘗試使用ListPicker控件對頁面嘗試捕捉語句,但它沒有解決問題。

在另一個(相關)筆記上,我可以通過簡單地將異常設置爲在App.Xaml中處理來避免該錯誤。那裏還有一個未處理的異常,我只是無視它。這種行爲是否可能導致我的應用被拒絕從商店?

任何幫助表示讚賞。

回答

1

好的,如此低的觀點和近一個星期沒有答覆,所以這裏是我通過谷歌找到這個的臨時修復。

在App.xaml中,我簡單地從顯示信息給用戶停止未處理的異常:

Public Sub Application_UnhandledException(ByVal sender As Object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException 
     ' Show graphics profiling information while debugging. 
     If Diagnostics.Debugger.IsAttached Then 
      'There is a bug in the WP Toolkit which throws an unhandled exception when GestureListener events are used within the app, 
      'and a ListPicker control is swiped over. Altering this method ignores these exceptions. 

      'Diagnostics.Debugger.Break() 
      e.Handled = True 

     Else 
      e.Handled = True 
      'MessageBox.Show(e.ExceptionObject.Message & Environment.NewLine & e.ExceptionObject.StackTrace, 
      '    "Error", MessageBoxButton.OK) 
     End If 
    End Sub 

這肯定不是一個理想的soultion,但我能想出替代的唯一的事情花費無數小時試圖規避工具包錯誤。自從上一次發佈以來已經有一段時間了,所以希望它能在下一個版本中得到修復。如果發生這種情況,我會編輯此答案,或者如果此修復程序阻止應用程序進入商店。

編輯:應用程序已成功提交到商店,所以雖然不是一個完美的解決方案,它將完成這項工作。

+0

你並不孤單!我遇到了同樣的問題,我使用了與您相同的解決方案。我使用下面的代碼片段過濾了異常(這是壞的代碼來修復壞框架哈哈) 'e.Handled =(e.ExceptionObject是ArgumentException)&& e.ExceptionObject.Message。Equals(「值不在預期範圍內。」)&& e.ExceptionObject.StackTrace.Contains(「at MS.Internal.XcpImports.MethodEx」);' – nverinaud

相關問題