Home  separator  Layout  separator  Wrap Panel
Bookmark and Share Share...    Subscribe to this feed Feed   About Christian Moser  


Wrap Panel

Introduction

The wrap panel is similar to the StackPanel but it does not just stack all child elements to one row, it wraps them to new lines if no space is left. The Orientation can be set to Horizontal or Vertical.

The WrapPanel can be used to arrange tabs of a tab control, menu items in a toolbar or items in an Windows Explorer like list. The WrapPanel is often used with items of the same size, but its not a requirement.

 
<WrapPanel Orientation="Horizontal">
    <Button Content="Button" />
    <Button Content="Button" />
    <Button Content="Button" />
    <Button Content="Button" />
    <Button Content="Button" />
</WrapPanel>
 
 




Last modified: 2010-03-02 11:01:47
Copyright (c) by Christian Moser, 2011.

 Comments on this article

Show all comments
vb guy
Commented on 1.June 2009
This is absolutely the most deatiled example of the Stack Panel I have ever seen! The author took no shortcuts here as all of the WPF StackPanel properties and events are clearly explained alone with Figures for the the more visual people. This link should be the authorative link for everything related to "Stack Panel". Cheers and thanks for the total effort!
thankful...
Commented on 22.June 2009
Vb Guy, if you want to learn more go to the MSDN. This is basic for the WrapPanel, and it's enough for the people who didn't know nothing about that. You must be truly thankful for the effort by the author of this site.
Dantarion
Commented on 23.July 2009
I agree. The fact that this website has pictures and plain-english explanations makes it the best website so far to just read to learn about the different components of WPF.

MSDN is good for API stuff, but for light reading and overviews, its not so great
Joel
Commented on 19.August 2009
In the second paragraph under "Introduction," it begins, "The StackPanel can be used..." -- I think you meant, "The WrapPanel can be used...."
Matt
Commented on 24.September 2009
No Joel, read it again… It makes sense. The paragraph is talking about common uses for each and where you would use a StackPanel as opposed to a WrapPanel.
Betsy
Commented on 22.October 2009
Thanks for the help. What panel would you use to hold images for a photo gallery?
raman
Commented on 28.January 2010
very nice
Me
Commented on 2.March 2010
I agree with VB guy... your just wasting everyones bandwidth.
Nomaan
Commented on 22.April 2010
wow is its a awesome tuturial
sssssss
Commented on 11.May 2010
so so tutorial. not so useful
4545
Commented on 11.May 2010
<WrapPanel Orientation="Horizontal">
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</WrapPanel>
Prasanta
Commented on 1.June 2010
Nice article.
suma
Commented on 15.June 2010
very nice
sm
Commented on 31.August 2010
nice and light article
Why
Commented on 24.September 2010
I agree with the comment about wasting bandwith.
cstill
Commented on 24.October 2010
I am new to WPF and am trying to convert a VB6 project to WPF using VB2010. We used a lot of Data Repeaters in the VB6 project and I am looking for a replacement for that in WPF. What would be the best replacement?
CuongDV
Commented on 4.January 2011
I have a wrap Panel. Now I want to add 1000 000 buttons into it. I write the method
private void AddButtons()
{
for (int i = 0; i < 10000; i++)
{
Button newBtn = new Button();
newBtn.Content = i.ToString();

wrapPanel1.Children.Add(newBtn);

}
}

But when run this code I see that the wrapPanel only display 1000 000 buttons after added 1000 0000 completely. Now I want after adding each button, the wrapPanel will updateLayout(or refresh) immediately so that I can see that button . Can you help me how to do that?
mike
Commented on 4.March 2011
Totally agree with vb guy. I am visually oriented, so images are the best. I think the xaml is too long to read.

The last paragraph should be titled conclusion for better clarity, text is too clutered.
Rahi,...
Commented on 21.May 2011
I am wandering again and again. Very nice job. Thanks
Miu
Commented on 22.June 2011

Thanks for to the point and simple description! Simplicity is rare! :)
Gourav
Commented on 28.June 2011
Thanks,Nice artical.....
Mike
Commented on 10.August 2011
I noticed this was copy righted. Can I still use a WrapPanel?
Roman P
Commented on 17.August 2011
Excellent and strait forward example!

Name
E-Mail (optional)
Comment