I have a scenario where I apply a custom RadListBoxItem DataTemplate to my ListBox which has been working correctly for months if not years.
I have been trying our program on a touch device for the first time (Surface Pro 2) and realised I cannot select any item (with touch) without causing the program to crash.
I have broken the fault down to a far simpler program which still shows the same problem.
<
telerik:RadListBox
x:Name
=
"lstmain"
/>
Dim DT As New DataTemplate With {.DataType = GetType(RadListBoxItem), .VisualTree = New FrameworkElementFactory(GetType(RadListBoxItem))}
lstmain.ItemTemplate = DT
lstmain.ItemsSource = Results
Results is a returned observable collection of C_SearchItem
Dim Results As New ObservableCollection(Of C_SearchItem)
Public Class C_SearchItem
Public ErrorCode As Integer
End Class
Using the above code. (RadListBox with default RadListBoxItem) causes the below error.
Object reference not set to an instance of an object.
at Telerik.Windows.Controls.Internal.ListBoxTouchableElement.TapDown(TapDownArguments args)
at Telerik.Windows.Input.Touch.TouchableElements.TapTouchableElementBase.Telerik.Windows.Input.Touch.TouchableElements.ITapTouchableElement.TapDown(TapDownArguments args)
at Telerik.Windows.Input.Touch.GestureHandlers.TapGestureHandler.TapUp(Point point)
at Telerik.Windows.Input.Touch.TouchHandler.RegisterTouchUp(TouchHandlerArgs args)
at Telerik.Windows.Input.Touch.TouchHandlersController.RegisterTouchUp(Point point, TouchPoint[] touchPoints, Boolean& handled)
at Telerik.Windows.Input.Touch.TouchHandlersController.Owner_TouchUp(Object sender, TouchEventArgs e)
at System.Windows.Input.TouchEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.TouchDevice.RaiseTouchUp()
at System.Windows.Input.TouchDevice.ReportUp()
at System.Windows.Input.StylusLogic.PromoteMainUpToTouch(StylusDevice stylusDevice, StagingAreaInputItem stagingItem)
at System.Windows.Input.StylusLogic.PromoteMainToTouch(ProcessInputEventArgs e, StylusEventArgs stylusEventArgs)
at System.Windows.Input.StylusLogic.PromoteMainToOther(ProcessInputEventArgs e)
at System.Windows.Input.StylusLogic.PostProcessInput(Object sender, ProcessInputEventArgs e)
at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.StylusLogic.InputManagerProcessInput(Object oInput)
at System.Windows.Input.StylusLogic.PreProcessInput(Object sender, PreProcessInputEventArgs e)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at ShieldServices1._7.App.Main() in C:\Applications\ShieldServices1.7\ShieldServices1.7\App.xaml.vb:line 25
If I replace RadListBox with the standard ListBox as follows there is no error.
<
ListBox
x:Name
=
"lstmain"
/>
Dim DT As New DataTemplate With {.DataType = GetType(ListBoxItem), .VisualTree = New FrameworkElementFactory(GetType(ListBoxItem))}
lstmain.ItemTemplate = DT
lstmain.ItemsSource = Results
I am using the latest release v.2015.1.401.45
Regards
Shaun Critten