What's the best method for setting the minimum size of a UserControl dynamically? #20224
Replies: 1 comment
-
|
I guess you want to get the min width of the window automatically based on the control's width/minwidth props, right? Haven't tested it in any way but maybe you can put it in a scrollviewer with an attached property and monitor the control's moment the scrollbar would appear (overflow) and then set the min width of the window? If this works, you could problably write a custom panel control monitoring content overflow which is hooked up to the top level to prevent it from being smaller. Actipro has a panel like this which they use for their toolbar to show overflowed items in a popup. Maybe you can do something similar but prevent the toplevel to get smaller instead. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What's the best method for constraining views/windows to prevent elements from overlapping / overflowing?
My example consists of a simple toolbar with a dynamic TextBox cell. It expands with the view and should be constrained to a minimum width.
Grid Layout
In this case, Grid.Measure returns a larger DesiredSize than the window and the view overflows. I'm aware this is intended Grid behaviour.
DockPanel Layout
I've tried using DockPanel but the elements end up overlapping.
In the past I've hardcoded the MinWidth property. This is tedious as I have to calculate the minimum width for each cell. I want the ability to dynamically style my views without having to worry about them breaking.
Beta Was this translation helpful? Give feedback.
All reactions