介绍
重新想象 Windows 8 Store Apps 之 ListView 和 GridView
ListView - 列表控件
GridView - 网格控件
示例
1、ListView 的 Demo
ListViewDemo.xaml
<Page x:Class="XamlDemo.Controls.ListViewDemo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:XamlDemo.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Page.Resources> <DataTemplate x:Key="ItemTemplate"> <StackPanel Orientation="Vertical"> <TextBlock TextWrapping="Wrap" FontSize="14.667" Text="{Binding Name}" HorizontalAlignment="Left" /> <TextBlock TextWrapping="Wrap" FontSize="14.667" Text="{Binding Age}" HorizontalAlignment="Left"/> </StackPanel> </DataTemplate> <Style x:Key="ItemContainerStyle" TargetType="ListViewItem"> <Setter Property="Width" Value="292" /> <Setter Property="Height" Value="80" /> <Setter Property="Padding" Value="0" /> <!-- 即使将 Margin 设置为“0”,也无法去掉 item 之间的 margin 如果想要去掉 item 之间的 margin,请将此 Margin 属性设置为“-4” --> <Setter Property="Margin" Value="0" /> <Setter Property="Background" Value="Blue" /> </Style> </Page.Resources> <Grid Background="Transparent"> <Grid Margin="120 0 0 0"> <TextBlock Name="lblMsg" FontSize="14.667" /> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0 30 0 0"> <CheckBox Name="chkIsSwipeEnabled" Content="IsSwipeEnabled" /> <CheckBox Name="chkIsItemClickEnabled" Content="IsItemClickEnabled" Margin="10 0 0 0" /> </StackPanel> <!--后台绑定方式为 ListView 提供数据--> <ListView x:Name="listView" Width="300" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0 60 10 10" BorderThickness="1" BorderBrush="Red" Background="LightBlue" ItemTemplate="{StaticResource ItemTemplate}" ItemContainerStyle="{StaticResource ItemContainerStyle}" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" SelectionMode="Single" SelectionChanged="listView_SelectionChanged_1" IsSwipeEnabled="{Binding IsChecked, ElementName=chkIsSwipeEnabled}" IsItemClickEnabled="{Binding IsChecked, ElementName=chkIsItemClickEnabled}" ItemClick="listView_ItemClick_1"> </ListView> <!-- xaml 方式为 ListView 添加内容 <ListView> <ListView.Items> <ListViewItem> ... </ListViewItem> <ListViewItem> ... </ListViewItem> ... </ListView.Items> </ListView> --> </Grid> </Grid> </Page>
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索windows
, listview
, 控件
, gridview
, 网格
, windows store app
, store
, listview图片gridview排序
, listview图片gridview网络
, ListView和GridView
listview内嵌gridview
,以便于您获取更多的相关知识。
时间: 2024-10-31 16:38:00