1

我想在 WPF ListBox(或 ItemsControl)中有类似 GridSplitter 的功能。以下代码不起作用,但演示了我想要实现的目标:

  <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>

有谁知道如何实现这一点?

4

1 回答 1

1

为什么不使用 ListView GridView?GridView 支持调整列大小。

于 2012-02-22T15:51:20.977 回答