开发者

How to Make ESC exits full-screen mode in Trusted Application?

开发者 https://www.devze.com 2023-01-03 10:59 出处:网络
One consequence of the keyboard-restriction change is that pressing ESC will not exit full-screen mode in trusted applications. 开发者_如何转开发This enables you to use the ESC key for other function

One consequence of the keyboard-restriction change is that pressing ESC will not exit full-screen mode in trusted applications. 开发者_如何转开发This enables you to use the ESC key for other functionality. However, you must provide your own user interface for exiting full-screen mode.

Reference: http://msdn.microsoft.com/en-us/library/ee721083(v=VS.95).aspx#fullscreen_support

I need to make pressing ESC will exit from full-screen mode in trusted application without provide a UI control in all pages.

Please give me hints, thank you.


This is the way you do it.

 private void UserControl_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape && App.Host.Content.IsFullScreen)
     {
         App.Host.Content.IsFullScreen = false;
     }
}

private void UserControl_Load(object sender, RoutedEventArgs e)
{
    this.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(UserControl_KeyDown), true);
}

By using the AddHandler method you can indicate that you want to recieve the keydown event regardless of whether it has been marked as handled by another control. Hence regardless of what control currently has the focus, the pressing of the Esc key should bubble up to the top.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号