✅ Help with XAML
I have a problem while designing my UI, I'm creating a panel (the app has dynamic UI so that it can fit any resolution) for the sake of simplicity let's say I have a bunch of buttons (quite big in size) inside a wrap panel so that the content is adjusted when the app is resized, but the problem is if the app is resized and there is not enough space to hold a button on the same row of the wrap panel it leaves a blank space until there is enough room to fit that button, so my question is, is there any way I can somehow extend the buttons to fill out that gap and then return to their original width once there is enough room to hold one more button in the wrap panel?
7 Replies
normally a viewbox is used for that have u tried it? https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/how-to-apply-stretch-properties-to-the-contents-of-a-viewbox?view=netframeworkdesktop-4.8
How to: Apply Stretch Properties to the Contents of a Viewbox - WPF...
Learn how to apply stretch properties to the contents of a Viewbox via the included code examples in XAML, C#, and Visual Basic.
assuming this is for WPF since u did not specify
Yes, I was asking for WPF and thank you I'll try it asap when I'm home and let you know!
Okay so the viewbox is expanding it's child contents but I can't seem to have the sequential positioning of the wrap panel, am I doing something wrong?
This is what my layout looks like:
ScollView -> StackPanel -> Bunch of Wrap Panels -> Buttons
I guess it's probably because I've placed the wrap panel inside the viewbox but then I can't have viewbox inside the wrap panel itself, I'm super confused at this point.
I don't know if I'm able to make myself clear but to make it more clear what I'm trying to achieve, go to your YouTube home page, and then zoom in, look how it auto expands the thumbnails of each video to fill out the empty space, that is what I want but only with the button's width, as the app is resized I'd like the buttons to expand to the right to fill out the empty space which the wrap panel does not by itself.
If all of the buttons have the same size, instead of a wrap panel you could try a UniformGrid. This will stretch the elements across the width of the control. You can then change the number of columns of the grid when resizing depending on how many items currently fit in a row.
Change the Width property on the buttons to MinWidth so they can expand.
can you perhaps post some images of what your app looks like without resizing and a bit more of the xaml used
That did the job, thank you so much ❤️
!close
Closed!