1

我需要像这张图片一样布局我的列表框

在此处输入图像描述

我已经为列表框和长列表选择器尝试了一切。

 <ListBox WP7Panels:DockPanel.Dock="Bottom" Name="MsgControlsList" 
                              ItemsSource="{Binding}" 
                              Height="600" 
                              HorizontalContentAlignment="Stretch"
                              VerticalAlignment="Bottom" VerticalContentAlignment="Bottom">
            <ListBox.Style>
                <Style TargetType="ListBox">
                    <Setter Property="VerticalAlignment"
            Value="Bottom" />
                    <Setter Property="VerticalContentAlignment"
            Value="Bottom" />
                </Style>
            </ListBox.Style>
            <ListBox.ItemTemplate>
            <DataTemplate>
                    <WP7Panels:DockPanel LastChildFill="True">
                        <HistoryClasses:HistoryElementTemplate WP7Panels:DockPanel.Dock="Bottom"  VerticalAlignment="Bottom" DataContext="{Binding}" HorizontalContentAlignment="Stretch"/>
                    </WP7Panels:DockPanel>
                </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel/>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    </WP7Panels:DockPanel>    

..但我仍然有列表框的顶部垂直对齐。

在此处输入图像描述

请问有什么想法吗?

4

1 回答 1

3

如果您不设置列表框的高度,则项目位于屏幕底部。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="600"/>
        <RowDefinition Height="Auto"/>
     </Grid.RowDefinitions>

     <TextBlock Text="Test"/>

     <ListBox Grid.Row="1"  VerticalAlignment="Bottom">
          <ListBox.ItemTemplate>
               <DataTemplate>
                    <TextBlock Text="Item"/>
               </DataTemplate>
           </ListBox.ItemTemplate>
      </ListBox>

      <TextBlock Grid.Row="2" Text="Test"/>

  </Grid>
于 2012-09-13T09:10:45.917 回答