我想在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