在 WinRT 中选择 XAML 的 ListView 和 GridView [英] Choosing between XAML's ListView and GridView in WinRT

查看:24
本文介绍了在 WinRT 中选择 XAML 的 ListView 和 GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XAML 中的 GridView 和 ListView 似乎是同一个控件.

The GridView and the ListView in XAML seem to be the same control.

开发者如何在两者之间做出选择?

推荐答案

GridView 控件通常水平滚动.此外,您将看到项目之间的一些原生间距大于 ListView 中的间距.之所以存在这种间距,是因为旨在考虑如何在 Windows 应用商店应用程序中使用这些控件.(继续阅读)

The GridView control typically scrolls horizontally. Also, you will see some native spacing between items that is greater than that in the ListView. This spacing is there because of the intent for how the controls will be used in Windows Store apps. (read on)

  • 与 ListView 一样,它继承自 ItemsControl.
  • 就像使用 GroupStyle 的 ListView 组一样.
  • 与 ListView 一样,它支持两种新的虚拟化策略.
  • 与 ListView 一样,它支持不同的选择模式.

示例语法:

<GridView>
    <x:String>Item 1</x:String>
    <x:String>Item 2</x:String>
</GridView>

ListView 控件通常垂直滚动.

The ListView control typically scrolls vertically.

示例语法:

<ListView>
    <x:String>Item 1</x:String>
    <x:String>Item 2</x:String>
</ListView>

这就是答案

两者之间的一般区别在于它们在视图中的出现.GridView 倾向于出现在 FullView、FillView 和 Portait 中.ListView 由于其垂直方向,往往会出现在 SnapView 中.任一控件都可以出现在任一视图中,但这是两个控件的局部转移.

The general differentiation between the two is their occurance in views. A GridView tends to appear in FullView, FillView, and Portait. The ListView, because of its vertical orientation, tends to appear in the SnapView. Either control can appear in either view, but this is the local diversion of the two controls.

MSDN:ListView 和 GridView 控件是两者都用于显示您的应用程序中的数据集合.它们具有相似的功能,但以不同的方式显示数据.它们都派生自 ItemsControl班级.当我们谈论 ItemsControl 时,该信息适用于两者ListView 和 GridView 控件.

MSDN: The ListView and GridView controls are both used to display collections of data in your app. They have similar functionality, but display data differently. They are both derived from the ItemsControl class. When we talk about an ItemsControl, the info applies to both the ListView and GridView controls.

ListView 显示垂直堆叠的数据.它通常用于显示项目的有序列表,例如电子邮件或搜索结果列表.它在主从方案中也很有用,其中列表项仅包含少量信息和所选内容的详细信息项目单独显示.

The ListView displays data stacked vertically. It's often used to show an ordered list of items, such as a list of emails or search results. It's also useful in master-detail scenarios, where the list items contain only a small amount of info and the details of the selected item are shown separately.

GridView 显示水平堆叠的数据.它经常用于当你需要展示每个项目的丰富可视化,需要更多空间,例如照片库.*

The GridView displays data stacked horizontally. It's often used when you need to show a rich visualization of each item that takes more space, such as a photo gallery.*

这篇关于在 WinRT 中选择 XAML 的 ListView 和 GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆