Page 1 of 1

Canvas PointerPressed event GetCurrentPoint throws exception [SOLVED]

Posted: Sat Oct 31, 2015 2:38 am
by binaryfish
I have a Canvas control (CnvGrid). I then capture the PointerPressed event of the Canvas control. When I click on the canvas the PointerPressed event is raised. However I get the error:

An unhandled exception of type 'System.NullReferenceException' occurred in CSharpXamlForHtml5.dll
Object reference not set to an instance of an object.

Below is the code:

Code: Select all

private void CnvGrid_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
   var pos = e.GetCurrentPoint(CnvGrid);
}
       


If I replace CnvGrid with this so line becomes e.GetCurentPoint(this) same problem.

Is this a bug?

Gavin

Re: Canvas PointerPressed event GetCurrentPoint throws exception

Posted: Sun Nov 01, 2015 3:31 am
by JS-Support @Userware
Hi Gavin,

Thanks for reporting this issue.

Yes, it is a bug. We have been able to successfully reproduce it.

It will be fixed in the very next build, which is expected in the next couple of weeks.

In the meantime, please use the following code to work around the issue:

Code: Select all

            // Get the absolute pointer coordinates:
            PointerPoint absolutePosition = e.GetCurrentPoint(null);

            // Get the opposite of the absolute position of the Canvas:
            GeneralTransform generalTransform = Window.Current.Content.TransformToVisual(CnvGrid);

            // Get the pointer coordinates relative to Canvas:
            Point relativePosition = generalTransform.TransformPoint(absolutePosition.Position);


Regards,
JS-Support

Re: Canvas PointerPressed event GetCurrentPoint throws exception

Posted: Tue Dec 22, 2015 11:30 am
by JS-Support @Userware
Hi,

The issue was fixed in C#/XAML for HTML5 Beta 6, which can be downloaded from:

http://forums.cshtml5.com/viewforum.php?f=6

Thank you.
Regards,
JS-Support