I've read so many solutions to this problem. Every one of them fails to solve my problem. No matter what container I put the control into or what properties I set on the control/container it will not budge.
I have a scroll viewer with a control within. I want it to resize with the window when the user resizes it at runtime. All I need is anchor=top, bottom, left, right
. I don't understand why this is so elusive in WPF and why container objects and all kinds of property assignments need to be involved to accomplish what a single property can in Windows Forms. But every solution to this problem still results in my control staying at exactly its design time size as the window is resized at runtime. What's the simple way to get a grip on dynamic control sizing in WPF?
This has caused me grief as well and AlexK helped me see the light. The trick is NOT to set the Height and Width.... Set these to AUTO
and use the MARGIN
to set the size. Set the HORIZONTALALIGNMENT
and VERTICALALIGNMENT
to STRETCH
and then the anchor functionality works.