question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[UWP] Using the navigation buttons on a mouse while the cursor is over a toucheffect control will throw a null reference exception

See original GitHub issue

On UWP, you can have navigation buttons on your mouse. This means that while you press them, it’ll trigger the pressed events, which will navigate to a different page but also attempt to do things like animate the background color of the affected control. However, as the app has since navigated to a different page, the control it is trying to act upon no longer exists and a null reference exception is thrown at

TouchVisualManager.cs line 195

 new Animation{
                {0, 1,  new Animation(v => sender.Control.BackgroundColor = new Color(v, sender.Control.BackgroundColor.G, sender.Control.BackgroundColor.B, sender.Control.BackgroundColor.A), sender.Control.BackgroundColor.R, color.R) },
                {0, 1,  new Animation(v => sender.Control.BackgroundColor = new Color(sender.Control.BackgroundColor.R, v, sender.Control.BackgroundColor.B, sender.Control.BackgroundColor.A), sender.Control.BackgroundColor.G, color.G) },
                {0, 1,  new Animation(v => sender.Control.BackgroundColor = new Color(sender.Control.BackgroundColor.R, sender.Control.BackgroundColor.G, v, sender.Control.BackgroundColor.A), sender.Control.BackgroundColor.B, color.B) },
                {0, 1,  new Animation(v => sender.Control.BackgroundColor = new Color(sender.Control.BackgroundColor.R, sender.Control.BackgroundColor.G, sender.Control.BackgroundColor.B, v), sender.Control.BackgroundColor.A, color.A) },
            }.Commit(sender.Control, ChangeBackgroundColorAnimationName, 16, (uint)duration, easing, (d, b) => animationCompletionSource.SetResult(true));

sender.Control is null so it’ll fail.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
MitchBomcanhaocommented, Jun 24, 2019

Yes, first impression is that it is working fine 😉

0reactions
AndreiMisiukevichcommented, Jun 24, 2019

@MitchBomcanhao does it work?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullReferenceException while navigating to a UserControl ...
UI.Xaml.Controls.Frame with a parameter that is not a type that inherits from Page, a NullReferenceException is thrown. The exception message is ...
Read more >
CoreWindow.PointerPosition returns nullReference
I'm trying to set the position of the mouse cursor inside of a UWP, but I keep getting a null reference exception that...
Read more >
OnMouseEnter() throwing NullReferenceException
The button is big and part of it is off the game tiles over empty space. I'm thinking that it's trying to call...
Read more >
How to remove cursor and use the gamepad in a UWP app?
When I run my application on XBOX using Visual Studio I'm getting a cursor by default which I wanted to remove and use...
Read more >
Null Reference Exception using Mouse.current on a laptop ...
I've been working on a game for a couple days now and have run into a snafu while using Mouse.current.position to read the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found