I would like to make my application such that it can maximize to full screen means it hide the windows task bar and the title bar as well. And it should triggered by a butto
I had this issue with the taskbar staying on top of my window. The current solution i use is setting the window as Topmost for a short time, then setting it back to false (i want my window to work nice with Alt+Tab)
private Timer t;
public void OnLoad()
{
var window = Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
StartTopmostTimer(window);
}
private void StartTopmostTimer(Window window)
{
t = new Timer(o => SetTopMostFalse(window), null, 1000, Timeout.Infinite);
}
private void SetTopMostFalse(Window window)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
window.Topmost = false;
}));
t.Dispose();
}
I also use this code to switch between full screen and window mode:
public void SwitchFullScreen()
{
var window = Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
if (window != null)
{
if (window.WindowStyle == WindowStyle.None)
{
window.WindowStyle = WindowStyle.SingleBorderWindow;
window.WindowState = state;
}
else
{
state = window.WindowState;
window.WindowStyle = WindowStyle.None;
window.WindowState = WindowState.Maximized;
window.Topmost = true;
StartTopmostTimer(window);
}
}
}