I am building a control depicting a diagram. The control’s content (which is rather complex) will try to scale to fit allotted space to the extent possible. However, not all scales are valid. The content cannot shrink indefinitely. E.g. a box on a diagram should be at least 20 pixels wide. Thus, when the window is too small to fit the content even at the minimum size, scaling should stop and scroll bars must appear.
I cannot find an elegant solution for this in WPF. Any design ideas are greatly appreciated.
Set the
Horizontal&VerticalAlignmentof the content toStretchbut also set theMinWidthandMinHeightto appropriate values, place your content in aScrollViewerwhoseHorizontal&VerticalScrollBarVisibilityis set toAuto.That should work, probably…
Example: