I am building a WP8 app. On the initial page of my app (after login), I am using the GestureService to manipulate the screen and create the effect of a slideout menu. This is all fine, but the problem is the GestureService is activated whenever a swipe action is performed on ListPicker controls on ANY other page of the app, and throws an unhandled Object reference not set exception, like so:
I've done some digging and this appears to be a bug within the WP Toolkit. The behaviour is the same on both the WP8 emulator and the Nokia WP8 dev phone I am using. According to this thread, I can use the ManipulationDelta and ManipulationCompleted events to achieve the same thing the GestureListener does. So I commented out the GestureService code and added Manipulation events onto the grid on my main page. Low and behold, the problem has disappeared.
Here is the GestureService call (on my initial xaml page), which is now commented out:
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DragDelta="GestureListener_OnDragDelta" DragCompleted="GestureListener_OnDragCompleted" />
</toolkit:GestureService.GestureListener>
The problem I am now facing is translating the code into the new format. Here is the Gesture code I am using (in 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
Not all the properties in the GestureListener are available/ comparable to the Manipulation events.
So am I best off soldiering on and attempting to recreate the effect within the Manipulation (if it's even possible), or does anyone know of a better way of doing this; i.e. a way of fixing or circumventing the bug to allow the GestureService to work...?
I already tried adding the GestureListener code and empty Try Catch statements to the pages with ListPicker controls on them, but it didn't solve the problem.
On another (related) note, I can avoid the error by simply setting the exception to Handled in App.Xaml. There is still an unhandled exception there, I'm just ignoring it. Is this behaviour likely to cause my app to be rejected from the store?
Any help is appreciated.