Showing posts with label WPF TextBox shrink stretch stackpanel dockpanel horizontalalignment "horizontal alignment" Grid. Show all posts
Showing posts with label WPF TextBox shrink stretch stackpanel dockpanel horizontalalignment "horizontal alignment" Grid. Show all posts

Friday, August 19, 2011

StackPanel cannot stretch properly

Context: I created a TextBox element and a button; both inside a StackPanel. And I put the StackPanel inside a Grid. I gave the StackPanel HorizontalAlignement.Stretch. And I don't want to give width to my TextBox .

Problem: My StackPanel is not expanding to fill the available space!!! even though I gave it Stretch for HorizontalAlignment.

Solution: use DockPanel.

Reasoning: StackPanel is designed to shrink as much as its children accept.