Svisstack
Svisstack

Reputation: 16656

WPF Panels - Non standard stacking

I want do some other item stacking but i dont have idea how simple do it. This is normal warp panel stacking (from left top to right top, and then dont have place then next item will be stacked on first left top free position):

enter image description here

But, i want do stacking from bottom right to top right and if don't have place to next item, then i want to next item will be stacked on first left bottom free place.

Like this:

|    X
|    X
|   XX
|   XX

Propably this can't be done using only WarpPanel i'm open to new ideas.

Can anyone help me?

Upvotes: 2

Views: 173

Answers (2)

Snowbear
Snowbear

Reputation: 17274

It is more a joke than a production code, but it works! :)

XAML:

    <Window.Resources>
        <Style TargetType="FrameworkElement" x:Key="rotateItPlease">
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <ScaleTransform ScaleX="-1" ScaleY="-1" />
                </Setter.Value>
            </Setter>
            <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
        </Style>
    </Window.Resources>

and then apply this style to both your WrapPanel and all it's children (it will be even more easier if you will have your wrapPanel as part of some ItemsControl):

    <WrapPanel Orientation="Vertical" Style="{StaticResource rotateItPlease}"> 
        <Button Style="{StaticResource rotateItPlease}">Hello</Button>
        <Button Style="{StaticResource rotateItPlease}">Hello</Button>
        <!-- More buttons here -->                       
    </WrapPanel>

Upvotes: 1

decyclone
decyclone

Reputation: 30840

I dont think you can customize WrapPanel to do that. But, you can always create a custom panel.

Search the web for custom panel implementation in WPF and you will get a lot of tutorials.

Upvotes: 0

Related Questions