[英]UWP align ListViewItem to bottom
這是簡單的列表視圖:
<ListBox>
<ListBoxItem Name="Home">
<RelativePanel>
<TextBlock Text=""/>
</RelativePanel>
</ListBoxItem>
<ListBoxItem Name="Map">
<RelativePanel>
<TextBlock Text=""/>
</RelativePanel>
</ListBoxItem>
<ListBoxItem Name="Settings">
<RelativePanel>
<TextBlock Text=""/>
</RelativePanel>
</ListBoxItem>
</ListBox>
如何在列表視圖的底部讓名稱Settings
為最后一個孩子? 這樣Map
和Settings
之間的空間將擴大到最大
只需使用具有4行的網格,例如“自動”,“自動”,“ *”,“自動”,然后將“設置”放到最后一行。
我不確定它是否也適用於ListBox,但是在ListView(這是ListBox的更新和更好的版本)中,您可以將ListViewItem放在頁腳中,將其放置在ListView的最底部,如下所示:
<ListView>
<ListViewItem Content="Home" />
<ListViewItem Content="Map" />
<ListView.Footer>
<ListViewItem Content="Settings" />
</ListView.Footer>
</ListView>
編輯:我剛剛發現在頁腳上單擊不是由ItemClick事件處理的,很遺憾,我還沒有找到任何可以處理該事件的事件。
這就是我的方法。 將行高設置為“ *”。 希望這可以幫助。
<RelativePanel>
<ListBox RelativePanel.AlignTopWithPanel="True" VerticalAlignment="Stretch">
<ListBoxItem Name="Home" >
<TextBlock Text="Home"/>
</ListBoxItem>
<ListBoxItem Name="Map">
<TextBlock Text="Map"/>
</ListBoxItem>
</ListBox>
<ListBox RelativePanel.AlignBottomWithPanel="True">
<ListBoxItem Name="Settings">
<TextBlock Text="Settings"/>
</ListBoxItem>
</ListBox>
</RelativePanel>
嘗試這個:
<ListView Name="MyListView" VerticalAlignment="Stretch" ItemsSource="{Binding MyListItems}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel VerticalAlignment="Bottom"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.