1

我需要布置我的列表框像这幅画垂直对齐列表框底部

enter image description here

我想尽一切办法做到这一点无论对于列表框和longlistselector ..

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

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

enter image description here

有什么想法吗?

+0

你的列表框中的代码是什么?也许一个网格或StackPanel? – BvdVen

+0

是的。它包裹在 ...

回答

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

它的工作原理!谢谢! –