Pages

Tuesday 12 March 2013

WrapPanel Control in WPF

WrapPanel Control in WPF Window Based

Wrap panel wraps all child elements to new lines if no space is left. 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.

Example:



XAML Code:

<Window x:Class="WpfApplication7.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="336" Width="430" Loaded="Window_Loaded">
    <Grid x:Name="LayoutRoot" Background="White" >
        <WrapPanel Orientation="Vertical" Margin="0,0,0,-39">
            <Image Source="2.jpeg" Width="102" Height="57"  />
            <Ellipse Width="80" Height="80" Fill="Orange" />
            <Image Source="2.jpeg" Width="100.224" Height="66"  />
            <Ellipse Width="40" Height="40" Fill="Green" />
            <Ellipse Width="20" Height="20" Fill="Blue" />
            <Rectangle Width="80" Height="80" Fill="DarkGoldenrod"></Rectangle>
            <Rectangle Width="60" Height="60" Fill="Chartreuse"></Rectangle>
            <Rectangle Width="40" Height="40" Fill="Coral"></Rectangle>
            <Rectangle Width="20" Height="20" Fill="DarkGoldenrod"></Rectangle>
        </WrapPanel>
    </Grid>
</Window>

No comments:

Post a Comment