if (!Application.Current.HasElevatedPermissions)
{
throw new NotSupportedException("This method requires elevated permissions.");
}
var content = Application.Current.Host.Content;
var dispatcher = Application.Current.MainWindow.Dispatcher;
if (!content.IsFullScreen)
{
// do this asynchronously; that will also work
// in certain event handlers like FrameworkElement.Loaded
dispatcher.BeginInvoke(() =>
{
// switch to full screen
content.IsFullScreen = true;
if (!content.IsFullScreen)
{
// something went wrong
Application.Current.MainWindow.width = 0;
Application.Current.MainWindow.height= 0;
return;
}
int width = (int)Math.Round(content.ActualWidth);
int height = (int)Math.Round(content.ActualHeight);
// switch back to windowed mode
content.IsFullScreen = false;
Application.Current.MainWindow.width = width;
Application.Current.MainWindow.height= height;
});
No comments:
Post a Comment