使用分隔条使ItemsControl的子项可调整大小

5

我想将部件插入到我的 ItemsControl 中,并使它们可调整大小。我该如何实现?

这是我的 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>

它绑定到哪里:
public List<string> TestForList
{
    get
    {
        return new List<string> { "A", "B", "C" };
    }
}

我希望能够在项目之间添加分隔器,以便可以调整它们的大小。有没有内置的工具可以实现这一点?

enter image description here

2个回答

1

我认为没有内置的功能可以做到这一点。我的第一个想法是,您需要创建自己的自定义面板实现来处理此问题。


1

您应该能够添加一个装饰器。我可以做一个样本,但我不想这么做。请查看这篇文章this be the article


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接