I've been working with WPF and xaml for less than a year some I would still consider myself a novice.
So I know there are similar questions and I was trying to sift through them to find the answer.
I'm trying to resize the contents of the window upon the user resizing and to also keep the aspect ratio of the original design.
I saw to use a viewbox in general to adjust the scalability of the controls - this works great with the stretch set to uniform.
My problem lies when you re-scale the windows width or height substantially, there are white dead space bars around the outside of the viewbox control, which is not a desired look. Ive seen the window property for size to content (this gets disregarded when dragging the window and doesnt work to re-enable it). It seems that the view box resizes correctly but the window does not.
I've tried calculating the width and height and setting it directly with the size_changed event of the window, this only works when setting one value (width or height).
I've looked into changing the width and height by adding a hook with source_initialized and checking the WINDOWPOSCHANGING of the window. This seems to work upon the preview dragging but when when I release the hold, the window goes back to the original position without any change (this also only works with a one way set of width or height).
Ive also seen the flickering of the window as well and am going to look into the EXITSIZEMOVE message.
If any operation is the correct way, resizing does not seem to work when setting both width and height or calculating one and setting the other..
My question is,
Is there a way this can work through xaml only for smoothness and faster rendering, getting rid of the white space?
Is the better performance or correct way to resize through the hook?
Am I missing something obvious with xml or the hook or is this a normal 'problem'?
EDIT: This needs to work for resizing from any window edge drag. Not just the Width or just the right side.
I appreciate the feedback.
General xml is:
<Window Height="800" width=1000">
<Viewbox>
(All controls)
</Viewbox>
<Window>