Template10 throws exception on launch when my phone is set to High Contrast
See original GitHub issueOnly happens when the color scheme is set to High Contrast. Here are the details of the exception:
Exception:
{“Object reference not set to an instance of an object.”}
StackTrace:
at Template10.Controls.HamburgerMenu.UpdateFullScreen(Nullable
1 manual)\r\n at Template10.Controls.HamburgerMenu.UpdateControl(Nullable
1 manualFullScreen)\r\n at Template10.Controls.HamburgerMenu.HamburgerMenu_Loaded(Object sender, RoutedEventArgs args)"
This even happens on newly created app using Template10’s templates in VS.
I am using VS 2015 for the development and the min and max version of the targeted OS are both set to Windows Anniversary Update.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
High contrast mode shows an error when turning off
This theme can't be applied to the desktop. Try clicking a different theme. [Close]. but im trying to turn it off, I don't...
Read more >How to Fix the Inability to Turn Off High Contrast Mode on ...
Start with basic troubleshooting and use the hotkeys to disable the high contrast theme. Then, update GPU drivers and Windows OS and reinstall ......
Read more >Some settings aren't available in High Contrast mode
This article explains how to disable the High Contrast mode and remove Some settings aren't available in High Contrast mode message in ...
Read more >eo
Exeter to barnstaple train, Delta com manage my booking, Us dept of education phone number, Is patriotism illegal in britain, Aeg competence oven...
Read more >QL-810W QL-820NWB
Set the contrast of the LCD. The higher the number, the stronger the contrast. Backlight. On. Off. Switch the backlight On or Off....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I ran into the same problem using the Template10 Hamburger template. I’ve downloaded the Template10 code, ran the debugger on the Hamburger template code and found that there’s a problem with the defined brushes in the default Custom.xaml HighContrast resource dictionary.
The brushes for the HamburgerMenu control in HightContrast are assigned a SystemColor instead of a brush. This will cause all the defined brushes of the control to be set to null in the constructor by the InitializeComponent method. Later on, the UpdateFullScreen method is called where the Opacity of the HamburgerBackground is set, but set to null this will throw a NullReferenceException.
So, changing the defined colors to brushes will fix the problem.
As a side note, there’s another issue with the default Custom.xaml. It uses style setters inside the ThemeDictionaries, the problem with that is if the user changes the light/dark setting on the Settings page it will not update the color scheme of the controls. The app has to be restarted to reflect the change.
A better way is to define brushes (or other properties) with a unique name and assign that brush in every theme. Then outside the ThemeDictionaries use the style setters to set the brushes of the controls once and refer to the unique brush names as a ThemeResource. This way if the user changes the light/dark theme it will update the color scheme immediately.