我想在WPF ListBox(或ItemsControl)中使用类似GridSplitter的功能。下面的代码不工作,但我证明了想达到的目标:可调整大小的WPF ListBox/ItemsControl项目
<ListBox ItemsSource="{Binding MyCollection}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding MyTextProperty}" Margin="0,0,10,0"/>
<GridSplitter
Width="5"
Background="Red"
HorizontalAlignment="Right"
ResizeBehavior="CurrentAndNext"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
有没有人对如何实现这一点的想法?
什么部分“不起作用”? – 2012-02-22 15:23:45
GridSplitter将调整网格中的行/列的大小。你的代码有一个网格,每个列表框项目有一行和一列。分路器不会做任何事情。 – Phil 2012-02-22 15:39:39
@jberger:分网器 – eriksmith200 2012-02-22 20:41:18