Under review

Exception when touching tablet

Oystein Bjorke 5 years ago • updated by anonymous 5 years ago 2
This discussion was imported from CodePlex

ge75el wrote at 2014-07-29 18:16:
I use the current Version of OxyPlot on a Windows 8.1 32 bit tablet. When I touch the Plot-Window I got a System.NullReferenceException():

with the following callstack
Oxy.Plot.Wpf.dll!OxyPlot.Wpf.PlotView.OnManipulationStarted()
PresentationCore.dll!System.Windows.UIElement.OnManipulationStartedThunk()
...

On a PC, my application works fine but there I did not have Touchscreen Events.

My application was designed for Desktop and does not use excplicitally Touch Events but if so, it should not Crash.

Regards,
Georg

ge75el wrote at 2014-08-08 09:16:
The is only there when using OxyPlot.dll and OxyPlot.Wpf.dll from download here. It is away when compiling this DLLs from sources with Visual Studio 2013.

objo wrote at 2014-08-08 10:35:
at what line are you getting the null ref exception?

ge75el wrote at 2014-08-08 12:36:
I only have this Information:

Problemsignatur:
Problemereignisname: CLR20r3
Problemsignatur 01: BDCViewer.exe
Problemsignatur 02: 1.1.0.0
Problemsignatur 03: 53e4a545
Problemsignatur 04: OxyPlot.Wpf
Problemsignatur 05: 2014.1.319.1
Problemsignatur 06: 53b1ce0a
Problemsignatur 07: 246
Problemsignatur 08: 29
Problemsignatur 09: System.NullReferenceException
Betriebsystemversion: 6.3.9600.2.0.0.768.101
Gebietsschema-ID: 1031
Zusatzinformation 1: 5861
Zusatzinformation 2: 5861822e1919d7c014bbb064c64908b2
Zusatzinformation 3: 4754
Zusatzinformation 4: 47547fafc9a3073a5bbe8e69322a8db5

I think, it is here:
public partial class PlotView
{
    /// <summary>
    /// Called when the <see cref="E:System.Windows.UIElement.ManipulationStarted" /> event occurs.
    /// </summary>
    /// <param name="e">The data for the event.</param>
    protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
    {
        base.OnManipulationStarted(e);
        if (e.Handled)
        {
            return;
        }

        e.Handled = this.Controller.HandleTouchStarted(this, e.ToTouchEventArgs(this));
    }
		
CodePlex
I had the same problem and figured out that the Controller property of the wpf PlateView control is always null. That causes the exception.
To solve this problem I created a new PlottController in the viewmodel and bind it to the PlateView.Controller property.
I think TouchscreenEvents should check if the Controller is null, as it checked in the ActualController property.
Under review
Thanks for the reminder! I have pushed a bug fix to the develop branch now!