【发布时间】:2012-05-20 20:42:56
【问题描述】:
与 AppBar 一起实现列表视图多选场景的最简单方法是什么? So that it behaves exactly as the Windows 8 start screen when multiple items selected (e.g. via the mouse right-click).
我想将应用栏与第一个选定的列表视图项目一起显示,我想保持它与第二个、第三个等一起打开,我想通过任何应用栏按钮操作(执行的上下文操作)来关闭它) 或通过其他系统范围的应用栏关闭操作(例如,右键单击其他位置,这意味着上下文操作已取消)。
我目前的实现太复杂了。我相信我一定错过了一些东西——这样一个基本和常见的场景必须可以以标准化的方式实现。
下面准备的脚手架代码。如果仅使用此代码,则应用栏在右键单击第二个列表视图项之前隐藏,并且需要再次右键单击列表视图(不可接受)。如果与 IsSticky 结合使用,则根本无法选择第二个列表视图项。
<Page
x:Class="ListViewAndAppBar.ExamplePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ListViewAndAppBar"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding ExamplePageViewModel, Source={StaticResource Locator}}">
<Grid Background="Gray">
<ListView
x:Name="ListView"
ItemsSource="{Binding Persons}"
SelectionMode="Multiple"
SelectionChanged="ListView_SelectionChanged">
</ListView>
</Grid>
<Page.BottomAppBar>
<AppBar x:Name="BottomAppBar" Padding="10,0,10,0">
<Button x:Name="BottomAppBarBack" Tag="Back" Style="{StaticResource BackAppBarButtonStyle}" HorizontalAlignment="Left" />
</AppBar>
</Page.BottomAppBar>
</Page>
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.BottomAppBar.IsOpen = true;
//this.BottomAppBar.IsSticky = true;
}
【问题讨论】:
标签: c# xaml windows-8 windows-store-apps appbar