Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making ItemsControl childs resizeable with a splitter

Tags:

c#

layout

wpf

xaml

I want to insert widgets into my ItemsControl and make them resizeable. How do I achieve this?

This is my XAML:

<ItemsControl ItemsSource="{Binding TestForList, Mode=OneWay}">

    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal"                
                        VerticalAlignment="Stretch"                
                        HorizontalAlignment="Stretch" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Border Margin="5" 
                    BorderThickness="1" 
                    BorderBrush="Black">
                <TextBlock FontSize="100" Text="{Binding}" />    
            </Border>                    
        </DataTemplate>
    </ItemsControl.ItemTemplate>

</ItemsControl>

Which binds to:

public List<string> TestForList
{
    get
    {
        return new List<string> { "A", "B", "C" };
    }
}

I want to somehow add splitters between items so they can be resized. Is there anything built-in to achieve this?

enter image description here

like image 336
katit Avatar asked Nov 04 '22 22:11

katit


2 Answers

You should be able to add an adorner. I would do a sample up, but I don't want to. Have a look at this article this be the article

like image 63
Nogusta Avatar answered Nov 09 '22 14:11

Nogusta


I don't think there's anything built-in to do this. My first thought is that you'll need to create your own custom Panel implementation that handles this.

like image 30
Tim Avatar answered Nov 09 '22 12:11

Tim