“ {DependencyProperty.UnsetValue}”不是属性“ FocusVisualStyle”的有效值 [英] '{DependencyProperty.UnsetValue}' is not a valid value for property 'FocusVisualStyle'

查看:580
本文介绍了“ {DependencyProperty.UnsetValue}”不是属性“ FocusVisualStyle”的有效值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的错误,我尝试调试时没有运气。

I have a weird error I'm trying to debug with no luck.

我将显示某些内容的hwndhost子类化了,在该类中我有以下函数可以设置为全屏:

I have subclassed hwndhost showing some content, I have the following function in that class to set to fullscreen:

    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;
        }
    }

这在我的原型WPF应用程序中很好用,但是当我在我的主应用程序中使用此代码,当关闭窗口(退出键)并在 fs.close()调用中时出现此错误:

This worked fine in my prototype WPF app but when I use this code in my main app I get this error when closing the window (escape key) and on fs.close() call:

'{DependencyProperty.UnsetValue}'不是属性'FocusVisualStyle'的有效值。

奇怪的是,它在窗口关闭后约1500ms发生。我尝试将 fs 上的FocusVisualStyle设置为null,但看起来却有些不同。没想到,这是我试图在应用程序中聚焦另一个不具有此属性的元素,但实际上我不知道!

The weird thing is it happens about 1500ms AFTER the window closes. I've tried setting FocusVisualStyle on fs to null, but it looks like something else. Gut feeling is it's trying to focus another element in my app that doesn't have this property, but really I have no idea!

谢谢!

编辑。问题是我的全屏按钮上的FocusVisualStyle的自定义设置。我设置为{x:Null},问题就消失了。

Edit. Problem was custom setting of FocusVisualStyle on my fullscreen button. I set to {x:Null} and the problem went away.

推荐答案

我的猜测是,当关闭窗口时,您设置的自定义样式不包含任何FocusVisualStyle。

my guess is that the control that gets the focus when you close the mentioned window has a custom style set by you that does not include any FocusVisualStyle.

因此,为了进一步帮助您,您应该多说明一点:发生了什么(还是应该发生),当您关闭此窗口时?

so to help you further, you should explain a bit more: what happens (or should happen) when you close this window?

应该使用哪种控件类型来获取焦点?

what control type is supposed to get the focus?

这篇关于“ {DependencyProperty.UnsetValue}”不是属性“ FocusVisualStyle”的有效值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆