Recently I stumbled across an issue while working on a custom WPF form. (aren't they all custom anyway?). I added the following properties to the XAML.
AllowsTransparency="True"
ResizeMode="NoResize"
Height="945"
Width="1621"
WindowStyle="None"
As well as a custom background image with the size listed above:
<Window.Background>
<ImageBrush ImageSource="Images/form_bg.png" />
</Window.Background>
And after running it, some buttons which I had added, simply vanished. It wasn't until after I supersized the buttons (approx 300
height & width) that they started to appear.
It took me a little while trying to figure out what was going on.... Windows was resizing my form because it did not fit on my 15
" laptop! Being only 1366 x 768
, my Windows 8.1
simply resized the form, shrinking it to, I think, 70%
of its original size. Since my controls use margins, and the XAML code was left untouched, but the actual form size reduced, my controls simply collapsed.
Now the obvious solution would be to make the image smaller, perhaps cropping it up a bit. Let's take 1280x1024
as a common resolution and make that fit. However, what if someone using a 1024x768
monitor runs that and it screws up on his end?
I managed to fix Windows' resizing by adding the MinWidth and MinHeight properties and setting them to the same values as Width & Height, but after moving the form, some of the bottom content simply drops off screen.
So, what I'm looking for is a proper way to deal with this. A decent user friendly solution. If perhaps I could have my controls resize along, the user might have trouble reading some of the content on a small screen.
Alternatively, perhaps I could maintain focus on a portion of the window using C#, regardless of its position? As long as that portion does not drop off screen that is.
Any tips, hints & samples greatly appreciated!