WPF C# Make window's the same width as the screen
-
Hi! I am trying to make a window that when it starts, takes up the entire width of the screen, regardless of resolution. I have tried to set the Width to 100% and to bind it to the primary screen width
Width="{Binding SystemParameters.PrimaryScreenWidth}">
But neither worked :(. Anyone have any idea on how to do it?
Have a nice day
-
Hi! I am trying to make a window that when it starts, takes up the entire width of the screen, regardless of resolution. I have tried to set the Width to 100% and to bind it to the primary screen width
Width="{Binding SystemParameters.PrimaryScreenWidth}">
But neither worked :(. Anyone have any idea on how to do it?
Have a nice day
-
Hi! I am trying to make a window that when it starts, takes up the entire width of the screen, regardless of resolution. I have tried to set the Width to 100% and to bind it to the primary screen width
Width="{Binding SystemParameters.PrimaryScreenWidth}">
But neither worked :(. Anyone have any idea on how to do it?
Have a nice day
Try:
Width="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}"
c# - WPF Binding from System.Windows.SystemParameters.PrimaryScreenWidth with a Converter - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Try:
Width="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}"
c# - WPF Binding from System.Windows.SystemParameters.PrimaryScreenWidth with a Converter - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Hi! SO close :) It gives a very small gap between the screen edge and the window. I took a screenshot of the screen so that I could zoom in and check how many pixels there was between the window and the screen. It's around 8 pixels gap on the right side. And even if I set Left and Top to 0, I get one pixel from the top and 8 from the Left. Here is the XML code for the window that I have now:
I would want it go to to the edge and there to be no gaps. Thanks for the help so far :)
Have a nice day! Thinking of getting a new IDE!
-
Hi! SO close :) It gives a very small gap between the screen edge and the window. I took a screenshot of the screen so that I could zoom in and check how many pixels there was between the window and the screen. It's around 8 pixels gap on the right side. And even if I set Left and Top to 0, I get one pixel from the top and 8 from the Left. Here is the XML code for the window that I have now:
I would want it go to to the edge and there to be no gaps. Thanks for the help so far :)
Have a nice day! Thinking of getting a new IDE!
Is it possible you are looking for Kiosk mode? c# - WPF application in Kiosk mode - Stack Overflow[^]
Never underestimate the power of human stupidity - RAH I'm old. I know stuff - JSOP
-
Hi! SO close :) It gives a very small gap between the screen edge and the window. I took a screenshot of the screen so that I could zoom in and check how many pixels there was between the window and the screen. It's around 8 pixels gap on the right side. And even if I set Left and Top to 0, I get one pixel from the top and 8 from the Left. Here is the XML code for the window that I have now:
I would want it go to to the edge and there to be no gaps. Thanks for the help so far :)
Have a nice day! Thinking of getting a new IDE!
Create a (dummy) maximized window in the background and copy it's properties (e.g. width) to your actual "centered" window.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
Create a (dummy) maximized window in the background and copy it's properties (e.g. width) to your actual "centered" window.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
I was about to try Gerry's suggestion when I decided to test retriving the screen width with code and set the window size to it. It worked, but I wonder, is there not a way to do this without using code in WPF? Here is the code I used if someone is interested:
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth+2;
Note that +2 is there since the Windows Left parameter in the XML are set to -2, had to compensate for that or I get a small gap to the right. I put it right below the "InitializeComponent();" call.
Have a nice day! Thinking of getting a new IDE!
-
I was about to try Gerry's suggestion when I decided to test retriving the screen width with code and set the window size to it. It worked, but I wonder, is there not a way to do this without using code in WPF? Here is the code I used if someone is interested:
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth+2;
Note that +2 is there since the Windows Left parameter in the XML are set to -2, had to compensate for that or I get a small gap to the right. I put it right below the "InitializeComponent();" call.
Have a nice day! Thinking of getting a new IDE!
If you want to perform mathematical functions on the bound value, you'll need a converter - for example: GitHub - hexinnovation/MathConverter: A WPF Converter class that does it all[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer