I have a strange error that I am trying to debug without luck.
I have a subclassed hwndhost showing some content, I have the following function in this class to set full screen mode:
private void SetFullScreen(bool enable) { if (enable) { fs = new Window(); fs.ResizeMode = ResizeMode.NoResize; fs.WindowState = System.Windows.WindowState.Maximized; fs.WindowStyle = System.Windows.WindowStyle.None; fs.Topmost = true; fs.PreviewKeyDown += delegate(object sender, KeyEventArgs e) { if (e.Key==Key.Escape) FullScreen = false; }; fs.Show(); } else { fs.Close(); fs = null; } }
This works fine in my prototype WPF application, but when I use this code in my main application, I get this error when I close the window (escape key) and when fs.close() called:
'{DependencyProperty.UnsetValue}' is not a valid value for property 'FocusVisualStyle'.
It is strange that this happens after about 1500 m. AFTER the window is closed. I tried setting FocusVisualStyle on fs to null, but it looks like something else. Feeling tired is an attempt to focus another element in my application that does not have this property, but in fact I have no idea!
Thanks!
Change The problem was setting FocusVisualStyle on my fullscreen button. I installed {x: Null} and the problem disappeared.
wpf dependency-properties
Daveo
source share