A WPF component for displaying a list of elements in a horizontal or vertical stack.
Questions tagged [stackpanel]
629 questions
15
votes
1 answer
WPF how make StackPanel Scrollable
in a stackpanel i add some labels from code behind at runtime: i want make the stackpanel scrollable. In the xaml file i have:

Tom
- 4,007
- 24
- 69
- 105
15
votes
3 answers
Spacing buttons equally across a window in WPF
What's the best control to arrange buttons horizontally across a window in WPF?
I am having trouble arranging the buttons evenly while resizing the window. I tried to use the stack panel but the buttons just stay at their position and do not space…

Saurabh Lalwani
- 705
- 2
- 7
- 15
15
votes
3 answers
Looping through StackPanel children in WPF
I have a StackPanel that is full of controls, I am trying to loop through the elements and get their Names, but it seems that I need to cast each element to its type in order to access its Name property.
But what if I have a lot of different types…

user1590636
- 1,174
- 6
- 26
- 56
14
votes
1 answer
How can I get StackPanel to use an ItemTemplate?
In the following code, I tell the ComboBox to use the DataTemplate called CustomerTemplate by assigning its ItemTemplate attribute.
StackPanel, however, doesn't have an ItemTemplate attribute.
How can I get the StackPanel to also use…

Edward Tanguay
- 189,012
- 314
- 712
- 1,047
13
votes
2 answers
Horizontal Stackpanel Fill Parent Control
Is it possible to have a or labels (or buttons, whatever) going horizontally across it's parent control (e.g. Window) and have it fill out all the space allowed?
For example if I had 3 controls
_ window width__
[ 1 ]__ [ 2 ] __ [ 3…

Ternary
- 2,401
- 3
- 31
- 54
13
votes
3 answers
How to make items in a DockPanel expand to fit all available space in WPF?
I have a StackPanel containing a StackPanel and some other items. The first StackPanel has a vertical orientation, the the inner one has a horizontal orientation. The inner one has a TreeView and a ListView, I would like them to expand and fit the…

LM.
- 1,625
- 3
- 16
- 23
12
votes
4 answers
WPF StackPanel content vertical alignment
Is there a way in XAML to say that I want to center-align vertically all components inside a horizontal-oriented StackPanel?
I achieve the desired result with the below XAML:

Nuts
- 2,755
- 6
- 33
- 78
12
votes
4 answers
How can I vertically align a TextBox inside a StackPanel?
In the following XAML, the word "Test" centers horizontally but not vertically.
How can I get it to center vertically?

Edward Tanguay
- 189,012
- 314
- 712
- 1,047
11
votes
4 answers
Why won't StackPanel put textblock on left and button on right in Silverlight?
OK, I give up: what do I have to change to this StackPanel below so that it puts the:
text on far left of form
button on far right of form.
alt text http://tanguay.info/web/external/stackPanelLeftRight.png

Edward Tanguay
- 189,012
- 314
- 712
- 1,047
11
votes
2 answers
Grid inside a StackPanel: why do auto and * behave strangely?
My google and stackoverflow search-fu have failed me, so I present to the community this question.
(This is all generated using VS2010 and .NET 4.0, in a blank default WPF Solution)
Consider the following XAML:
…

pfw
- 237
- 3
- 9
11
votes
1 answer
Two Rows in a Horizontal Stack Panel? (WPF)
I have this stack panel (contains four fractions):
(Fractions are just text with new lines and hyphens.) If I add a fifth fraction, it'll go to the right of 10/12, instead of forming a second row.
How do I configure my StackPanel so that it'll…

ashes999
- 9,925
- 16
- 73
- 124
10
votes
1 answer
How to implement Camera app style photo strip on WP7?
I'm running into a number of problems creating an effect very similar to the photo strip in the Camera app.
All I want to do is display a row of grids that each have the same dimensions as the screen (whether in portrait or landscape). Already, I…

Subcreation
- 1,353
- 12
- 26
10
votes
3 answers
Best method to build data entry forms in WPF?
When building WPF forms that are used for data entry (e.g. A bunch of labels next to a bunch of textboxes and comboboxes) I've seen two methods:
Create a master Grid, divide it into two columns, and add rows with Height="auto" for each field and…

Ziv
- 2,755
- 5
- 30
- 42
10
votes
6 answers
Stack Panel Or Grid which one is most advisable
I heard that UI Design with Stack panel is more promotable that Grids. Is there any fact present in that. I am usually using Grid for Designing my UI, recently in a document i read that the Grid consumes more time for rendering rather than stack…

Rakesh R Nair
- 1,736
- 2
- 12
- 30
10
votes
1 answer
WPF - Animating a change in orientation of a stackpanel?
I'm trying to create an animation where an icon (a xaml vector graphic on a Viewbox-wrapped Canvas) goes from having its text (TextBlock) beside it to underneath it.
I currently have the Viewbox and TextBlock in a Horizontally oriented StackPanel. …

Nick W.
- 1,050
- 2
- 9
- 21