Tutorial :Windows Font Size screws up WPF application



Question:

We're having this weird bug where if the application is opened and the user changes the windows font size here:

alt text

When the font size is changed to extra large, one of our controls DataContext is changed to null, and its DataContextChanged event is called too.

Not really sure what is going on, nor why or what changes the DataContext of the control. Any help would be greatly appreciated.

Thanks!


Solution:1

I'm assuming ChartItemControl is a System.Windows.Controls.Control or UserControl. A Control's Unloaded event will be fired when modifying the windows theme, color scheme, or font size. If you are cleaning up resources by resetting DataContext when handling the Unloaded event, you will need to reset your DataContext when the control is loaded again or in OnApplyTemplate.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »