How to create wrap panel in wpf application ?

Leave a Comment
Here i am demonstrating wrap panel implementation for wrap panel in wpf application. I will show you how to use wrap panel for horizontal view and vertical view also.

MainWindow

This is for verticle wrap panel view.

<Window x:Class="Wrappanel.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <!--set orientation vertical or horizontal-->
    <WrapPanel Orientation="Vertical">
        <Rectangle Fill="AliceBlue" Height="100" Width="100"/>
        <Rectangle Fill="Red" Height="100" Width="100"/>
        <Rectangle Fill="Green" Height="100" Width="100"/>
        <Rectangle Fill="Pink" Height="100" Width="100"/>
        <Rectangle Fill="Black" Height="100" Width="100"/>
        <Rectangle Fill="Green" Height="100" Width="100"/>
        <Rectangle Fill="Pink" Height="100" Width="100"/>
        <Rectangle Fill="Black" Height="100" Width="100"/>
        <Rectangle Fill="AliceBlue" Height="100" Width="100"/>
        <Rectangle Fill="Red" Height="100" Width="100"/>
        <Rectangle Fill="Green" Height="100" Width="100"/>
        <Rectangle Fill="Pink" Height="100" Width="100"/>
        <Rectangle Fill="Black" Height="100" Width="100"/>
        <Rectangle Fill="AliceBlue" Height="100" Width="100"/>
        <Rectangle Fill="Red" Height="100" Width="100"/>
       
    </WrapPanel>
   
</Window>
In  vertical output look like this.


For horizontal output it will look like this.



 

0 comments:

Post a Comment