I am working on an application that has a full screen mode. When the full screen button/key is pressed the application should take up the entire screen i.e. the windows taskbar also disappears.
this.Window= WindowState.Maximized;
this.Window= WindowStyle.None;
this.Fullscreen = true;
When I first start the application my fullscreen mode works as planned and the windows taskbar disappears. The problem is when I resize the window. After any resizing the full screen mode no longer takes up the entire screen. The windows taskbar is still there. It is not reasonable for me to disable window resizing (although that does solve the problem).
It was my understanding that WindowStyle.None removed the taskbar (it does at first). Does anyone know if resizing the window changes something that stops the WindowStyle.None from doing what it does upon first starting up.
EDIT:
I am using a viewbox to scale my content to fullscreen and the stretch of the viewbox in full screen mode is set to Fill
Try applying the WindowStyle first (before WindowState). That fixed it for me.
Edit: I also noticed that this doesn't work when the window is already maximized. Try this:
this.WindowState = WindowState.Normal;
this.WindowStyle = WindowStyle.None;
this.WindowState = WindowState.Maximized;
Instead of using WindowState
use SystemParameters
In your Window's constructor set the width and height
this.Width=SystemParameters.FullPrimaryScreenWidth;
this.Height=SystemParameters.FullPrimaryScreenHeight;
You can also have a look here
Related
I have a question related to how does the FormBorderStyle property works. When I set the property to Sizable, the Windows taskbar shows perfectly, but when I set it to other than that (e.g. FixedSingle, FixedDialog, etc.), the taskbar doesn't show, it is hidden behind the WinForms application. How can I set the FormBorderStyle to other than Sizable and still be able to see the taskbar?
EDIT: What I mean by the taskbar is the Windows taskbar, on which the applications are shown. This is an example with the FormBorderStyle set to Sizable:
image. As you can see, when you move the mouse to the bottom of the screen, the Windows taskbar shows.
In contrast, when I set the property to, for example, FixedSingle, this is what happens: image. The taskbar doesn't show.
In Windows 10, switching to Tablet Mode forces active windows to take the entire width and black out any underlying windows. We use small WPF windows as popup overlays for a dictionary tool. Most of the time they are not in focus, so the size stays right. However, if the user interacts with the popup, it will immediately expand. I can see several options for detecting Tablet Mode, but is there any way to prevent this from happening?
Update. Found this - perhaps it might help. https://social.msdn.microsoft.com/Forums/sqlserver/en-US/81bc4436-998e-4f4c-beb2-7c5edc36047b/how-to-prevent-form-from-being-maximized?forum=vbgeneral
If I understand you correctly, your windows are not supposed to be maximized at all. Then why not just prevent it with:
protected override void OnStateChanged(EventArgs e) {
base.OnStateChanged(e);
if (this.WindowState == WindowState.Maximized)
this.WindowState = WindowState.Normal;
}
In your window class.
I code an editor, that should have a fullscreen-mode (editor covers 100% of the screen, taskbar is not visible). "Set the Window Topmost" you would say, but hereĀ“s the problem: my editor runs external programs, that have to be visible.
My editor should hide the taskbar, but not be topmost for other applications. Is this possible? And how?
You don't need a TopMost window to cover the taskbar. Creating a borderless maximized window is enough:
public MainWindow() {
InitializeComponent();
this.WindowState = System.Windows.WindowState.Maximized;
this.ResizeMode = System.Windows.ResizeMode.NoResize;
}
You still need a way for the user to activate a window of another application. It isn't clear what you had in mind, but Alt+Tab works.
I already set this.WindowState = FormWindowState.Maximized; and everything looks ok but the Windows open-window icons (such as my browser at the bottom of the page) is still visible.
How to make it invisible?
I just figured out the answer
TopMost must be set to true together with FormBorderStyle = FormBorderStyle.None and Bounds = Screen.PrimaryScreen.Bounds.
I have recently written an application for my daughter, which is a kid-free zone where she has all unnecessary key presses ignored (windows key, Esc etc) but the problem I am having is that when I use the following code:
targetForm.WindowState = FormWindowState.Maximized;
targetForm.FormBorderStyle = FormBorderStyle.None;
targetForm.TopMost = true;
I am able to HIDE the taskbar, but it is not truly overlayed. When I move the mouse to where the taskbar would be, and click, it pops up, also, using this code and running external applications withing my windows form, I am left with this windows form keeping itself on top.
If anyone could help me with a proper way to display my windows form as a true fullscreen application, and be able to run external applications from within the form and have them prioritize themselves on top, that would be greatly appreciated.
In case you missed it, I am using VS2010, C# and winforms.
Thanks in advance!
The proper way to make a full-screen app is to just put something like Bounds = Screen.PrimaryScreen.Bounds; in your main form. Then when your app has focus it will cover the task bar.
You also probably want FormBorderStyle = FormBorderStyle.None;
The order of the performed actions is incorrect.
You should first hide the border (FormBorderStyle=None), and then set the window state to maximized. You even don't have to set TopMost to true.