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

它的工作原理!謝謝! –