Why can't the application window be resized to fit my screen (1920 x 1024)?


When I change the size of my app window I can't make it size bigger than 1226.4 x 8825.6 !
The same thing happen when the window is maximized.
I've tried to set WindowPlacement=string.Empty at startup but it does not change this behavior.

Here is what is stored in the WindowPlacement property :
( from Debug.WriteLine(this.WindowPlacement) during the Window Closing event)
<?xml version="1.0" encoding="utf-8"?><WINDOWPLACEMENT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><length>44</length><flags>0</flags><showCmd>1</showCmd><minPosition><X>-1</X><Y>-1</Y></minPosition><maxPosition><X>-1</X><Y>-1</Y></maxPosition><normalPosition><Left>32</Left><Top>32</Top><Right>1565</Right><Bottom>992</Bottom></normalPosition></WINDOWPLACEMENT>

Is there a way to release this constraint? Or is it "by-design" ?


rehansaeed wrote Dec 23, 2014 at 10:30 AM

Do you have multiple monitors? If so, what size are they?

Have you tried it without the WindowPlacement property binding set?

JBZ wrote Dec 23, 2014 at 6:00 PM

I' don't use the WindowPlacement property at all.
But after reading your comment I did a test:
My laptop screen DPI scaling size is generally set to 125% (I'm 53 years old :) ).
So I changed the scale back to 100% (Control Panel =>Display)
And it worked !!!!!
I could resize the app window up to the screen width and height.

Set-it back to 125% => don't work again.
In this scale, when I force the window size through code in the Window constructor, the app window resize to the "Limits" (1226.4 x 825.6) values as soon as I move, maximize, resize ... it.

Any idea?

JBZ wrote Dec 23, 2014 at 6:11 PM

did the test with 150% DPI scale => limits are 851.33333333333326 x 682.66666666666663.

rehansaeed wrote Dec 24, 2014 at 10:48 AM

Changing DPI is probably going to become a much more common activity as monitors with huge screen resolutions become more common.

I tried to set my work monitor (1280x1024 - Yes I know) to 125% and it seems ok. If I try 150% everything becomes unusable on such a low resolution screen.

I will have to give it a go at home when I can find the time. Have you tried setting the MaxHeight and MaxWidth properties? The code to do all this stuff is massively complicated because it involves Windows interop and a fair amount of calculation and I have to say I'm a little in the dark with it.

rehansaeed wrote Dec 24, 2014 at 10:58 AM

If you decide to take a look at the code yourself, it's all in the Window class and it's one of the few pieces of code that is not particularly pretty. The reason being that most of the API's provided by Elysium are private or internal so various workarounds had to be used to inherit from the Elysium Window.

Worse still, the Elysium window had a bug in it that would limit the maximum size of it to smaller than the available space, especially if you were using multiple monitors. Elysium Extra had to overcome this too.

Long term, I think it's probably best to not derive from the Elysium window at all and build it all from scratch but a fully themed WPF window is probably the hardest thing to do in WPF. There are so many edge cases and variables as you have found. There are other projects that provide one but I would need to test them all and see which of them works best.

wrote Jan 31, 2015 at 4:21 AM

alleey wrote Jan 31, 2015 at 4:32 AM

Thats a big let down, just cant change resize or truly maximize the window : (

alleey wrote Jan 31, 2015 at 10:29 AM

Funny thing, I just wanted to test and commented out the WndProc hook and it started working absolutely OK. I'm testing this on single monitor though and confused as to the purpose of WndProc. Grabbed source code from the installed nuget package's folder.
            Framework.UI - Window.cs

alleey wrote Jan 31, 2015 at 10:49 AM

Whereas by removing the hook the resize or maximize the window, it runs into another problem that the Window's top busy indicator is no longer visible in Fullscreen.

rehansaeed wrote Feb 2, 2015 at 8:43 AM

Yes, as you've found, it's not an easy fix. There are a number of open source Windows on CodePlex. When I get time (Pretty busy at the minute, so not sure when), I'll take a look. It would be great however, to get a community contribution.