After Modified screen dpi,Unloaded/Loaded is trigged unexpectedly
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
When I modify the system dpi in screen setting, a userControl in window raises unload event, as more amazing unload event of window that contains the userControl is not triggered.
As all I known, loaded/unloaded can be triggered by these cases:
FrameworkElement raises loaded/unloaded when it's added/removed to visual tree.
TabControl selection change from tab A to tab B, raise A'UnLoaded and B'Loaded
Expander、MenuItem and so on...All these cases, emmm.. seems like loaded/unloaded event raises just as element or it's parent leave from or add to wpf visual tree.
But, How Unloaded/Loaded can be raised by changing screen dpi ?
For testing, I create a window, then create and add a simple UserControl named A in window xaml, continue to create and add UserControl named B in A xaml. After window is showed in screen, modify screen dpi from 100% to 150%, UserControl A raise unloaded event, then UserControl B raise unloaded. As joking, window itself has no unloaded.
unloaded event stack:

As additional, before modify dpi setting, drag window and move near the taskbar, the issue occurs more probabily~

More details please see my blog https://www.cnblogs.com/kybs0/p/11943313.html
Expecting you advise for this bug~
Contributor guide
Assessment
This issue has not been assessed yet.