[源码下载]
背水一战 Windows 10 (56) - 控件(集合类): ListViewBase - 基础知识, 拖动项
作者:webabcd
介绍
背水一战 Windows 10 之 控件(集合类 - ListViewBase)
示例
1、ListViewBase 的基础知识
Controls/CollectionControl/ListViewBaseDemo/ListViewBaseDemo1.xaml
<Page
x:Class="Windows10.Controls.CollectionControl.ListViewBaseDemo.ListViewBaseDemo1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.CollectionControl.ListViewBaseDemo"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:common="using:Windows10.Common">
<Grid Background="Transparent">
<Grid Margin="10 0 10 10">
<StackPanel Orientation="Vertical">
<TextBlock Name="lblMsg1" />
<TextBlock Name="lblMsg2" Margin="0 10 0 0" />
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 10 0 0">
<CheckBox Name="chkIsItemClickEnabled" Content="IsItemClickEnabled" Margin="10 0 0 0" />
<CheckBox Name="chkShowsScrollingPlaceholders" Content="ShowsScrollingPlaceholders" Margin="10 0 0 0" />
<CheckBox Name="chkIsMultiSelectCheckBoxEnabled" Content="IsMultiSelectCheckBoxEnabled" Margin="10 0 0 0" />
<ComboBox Name="cmbSelectionMode" PlaceholderText="SelectionMode" SelectionChanged="cmbSelectionMode_SelectionChanged" Margin="10 0 0 0">
<ComboBoxItem>None</ComboBoxItem>
<ComboBoxItem>Single</ComboBoxItem>
<ComboBoxItem>Multiple</ComboBoxItem>
<ComboBoxItem>Extended</ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 10 0 0">
<Button Name="buttonScrollDefault" Content="滚动到第 101 条数据 ScrollIntoViewAlignment.Default" Click="buttonScrollDefault_Click" />
<Button Name="buttonScrollLeading" Content="滚动到第 101 条数据 ScrollIntoViewAlignment.Leading" Click="buttonScrollLeading_Click" Margin="10 0 0 0" />
<Button Name="buttonSelect" Content="选中第 3 到第 6 项" Click="buttonSelect_Click" Margin="10 0 0 0" />
</StackPanel>
</StackPanel>
<!--
ListViewBase(基类) - 列表控件基类
Header, HeaderTemplate, Footer, HeaderTransitions - 顾名思义,不用解释
HeaderTransitions - header 的过渡效果
FooterTransitions - footer 的过渡效果
IsItemClickEnabled - 点击 item 时是否会触发 ItemClick 事件(默认值为 false)
IsSwipeEnabled - 是否支持 swipe 操作(对于 ListView 来说,在触摸模式下,左右轻扫 item 称之为 swipe; 对于 GridView 来说,在触摸模式下,上下轻扫 item 称之为 swipe)
注:经测试,在 uwp 中这个属性无效(不支持 item 的 swipe 了)
SelectionMode - item 的选中模式
None - 不能被选中
Single - 只能单选(默认值)
Multiple - 支持多选,且支