[英]How to put a ListboxItem at the bottom of listbox in splitview uwp
So I have a listbox with several listboxItems but the last Item Name"ExampleBottom" needs to be at the bottom while the others need to stay on the top. 因此,我有一个包含多个listboxItems的列表框,但最后一个项目名称“ ExampleBottom”需要位于底部,而其他名称则需要保留在顶部。 I tried verticalalign but this doesn't work.
我尝试了verticalalign,但这是行不通的。
<SplitView.Pane>
<ListBox SelectionMode="Single"
SelectionChanged="ListBox_SelectionChanged"
Background="#333333"
Foreground="White">
<ListBoxItem Name="Example1">
<StackPanel Orientation="Horizontal">
<TextBlock>Example</TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="Example2">
<StackPanel Orientation="Horizontal">
<TextBlock>Example</TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="Example3">
<StackPanel Orientation="Horizontal">
<TextBlock>Example</TextBlock>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="ExampleBottom" VerticalAlignment="Bottom">
<StackPanel Orientation="Horizontal">
<TextBlock>Example</TextBlock>
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
I don't think you get this done with a listbox. 我不认为您可以通过列表框来完成此任务。 I would use a grid and then have a empty row in the middle but you need to implement your own Selection mechanism then
我将使用网格,然后在中间有一个空行,但是您需要实现自己的选择机制,然后
I've accomplished this using 2 list boxes inside a RelativePanel
. 我已经在
RelativePanel
使用2个列表框完成了此操作。
Have the first ListBox have a RelativePanel.AlignTopWithPanel = "True"
Have the second ListBox have a RelativePanel.AlignBottomWithPanel = "True"
使第一个列表框具有
RelativePanel.AlignTopWithPanel = "True"
使第二个列表框具有RelativePanel.AlignBottomWithPanel = "True"
Next, if you want it to look seamless, be sure the background color of your relative panel is the same as your ListBox(s). 接下来,如果要使其看起来无缝,请确保相对面板的背景颜色与ListBox相同。
<SplitView.Pane>
<RelativePanel Background="Black">
<ListBox SelectionMode="Single"
Name="IconsListBox"
SelectionChanged="ListBoxSelectionChanged"
Background="Black"
RelativePanel.AlignTopWithPanel="True">
<ListBoxItem Name="HomeListBoxItem"
ToolTipService.ToolTip="Home"
PointerEntered="HamburgerMenuItemPointerEntered"
PointerExited="HamburgerMenuItemPointerExited">
<StackPanel Orientation="Horizontal">
<TextBlock
Foreground="White"
FontFamily="Segoe MDL2 Assets"
FontSize="16"
Text="" />
<TextBlock
Foreground="White"
Text="Home"
FontSize="16"
FontFamily="Arial"
Margin="20,0,0,0" />
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="SecondListBoxItem"
ToolTipService.ToolTip="2nd Item"
PointerEntered="HamburgerMenuItemPointerEntered"
PointerExited="HamburgerMenuItemPointerExited">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="White"
FontFamily="Segoe MDL2 Assets"
FontSize="16"
Text="" />
<TextBlock
Foreground="White"
Text="Dosimetry"
FontFamily="Arial"
FontSize="16"
Margin="20,0,0,0" />
</StackPanel>
</ListBoxItem>
</ListBox>
<ListBox SelectionMode="Single"
Name="BottomListBox"
SelectionChanged="ListBoxSelectionChanged"
Background="Black"
RelativePanel.AlignBottomWithPanel="True">
<ListBoxItem Name="UserListBoxItem"
ToolTipService.ToolTip="Dosimetry"
PointerEntered="HamburgerMenuItemPointerEntered"
PointerExited="HamburgerMenuItemPointerExited"
VerticalAlignment="Bottom">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="White"
FontFamily="Segoe MDL2 Assets"
FontSize="16"
Text="" />
<TextBlock
Foreground="White"
Text="User"
FontFamily="Arial"
FontSize="16"
Margin="20,0,0,0" />
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="SettingsListBoxItem"
ToolTipService.ToolTip="Dosimetry"
PointerEntered="HamburgerMenuItemPointerEntered"
PointerExited="HamburgerMenuItemPointerExited">
<StackPanel Orientation="Horizontal">
<TextBlock Foreground="White"
FontFamily="Segoe MDL2 Assets"
FontSize="16"
Text="" />
<TextBlock
Foreground="White"
Text="Settings"
FontFamily="Arial"
FontSize="16"
Margin="20,0,0,0" />
</StackPanel>
</ListBoxItem>
</ListBox>
</RelativePanel>
</SplitView.Pane>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.