Reputation: 9081
I am developing a WPF application which will be displayed in Full screen. In addition, the application should work on many tablets of multiple dimensions. I'd like my application to run in full screen independently from its dimensions.
What is the best practice to accomplish this task?
Upvotes: 124
Views: 149165
Reputation: 61
This method worked for me when using ToggleButton to toggle between fullscreen and normal mode.
private void btnFullScreen_Click(object sender, RoutedEventArgs e)
{
if (this.WindowStyle == WindowStyle.None)
{
// Exit fullscreen
this.ResizeMode = ResizeMode.CanResize;
this.WindowStyle = WindowStyle.SingleBorderWindow;
//this.WindowState = WindowState.Normal;
}
else
{
// Enter fullscreen
this.ResizeMode = ResizeMode.NoResize;
this.WindowStyle = WindowStyle.None;
this.WindowState = WindowState.Normal;
this.WindowState = WindowState.Maximized;
}
}
Upvotes: 1
Reputation: 141
fullscreen:
oldstate = WindowState;
WindowState = WindowState.Maximized;
Visibility = Visibility.Collapsed;
WindowStyle = WindowStyle.None;
ResizeMode = ResizeMode.NoResize;
Visibility = Visibility.Visible;
Activate();
going back:
WindowState = oldstate;
WindowStyle = WindowStyle.SingleBorderWindow;
ResizeMode = ResizeMode.CanResize;
Upvotes: 1
Reputation: 12973
Set the WindowStyle to None, and the WindowState to Maximized. This can be done like this:
WindowState = WindowState.Maximized;
WindowStyle = WindowStyle.None;
Or in xaml:
<Window x:Class="FullScreenApplication.Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Full Screen WPF"
WindowState="Maximized"
WindowStyle="None">
And simply click ALT-TAB to escape from your full screen wpf. It allows you to switch between other applications.
Upvotes: 54
Reputation: 292635
Just set the WindowState
to Maximized
, and the WindowStyle
to None
.
Upvotes: 225