windows-8 - 在 WinRT 中选择 XAML 的 ListView 和 GridView

标签 windows-8 windows-runtime windows-store-apps winrt-xaml

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

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

最佳答案

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

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

  • 示例语法:
    <GridView>
        <x:String>Item 1</x:String>
        <x:String>Item 2</x:String>
    </GridView>
    

    ListView 控件通常垂直滚动。

    示例语法:
    <ListView>
        <x:String>Item 1</x:String>
        <x:String>Item 2</x:String>
    </ListView>
    

    这就是答案

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

    enter image description here

    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.

    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.

    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.*

    关于windows-8 - 在 WinRT 中选择 XAML 的 ListView 和 GridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10903669/

    相关文章:

    有关未定义或 null 引用的 JavaScript 运行时错误

    security - 如何在 Windows 应用商店应用程序包中存储 "secret"字符串

    windows - 如何在Surface RT上卸载暂存的应用程序包?

    javascript - 有关使用 HTML/CSS/JavaScript 编写应用程序的 Windows 8 Metro 资源列表?

    c# - 在 FlipView 的 KeyDown 事件中处理方向键

    c# - 在 C# 中验证证书

    windows-8 - 我想知道为什么 Blend for Windows 8 删除了 "make into user control"功能

    .net - 如何规范化字符串?

    c# - 如何处理 StorageFile 操作的并发?

    c# - 在 WinRT - Windows 8 - Metro App 中上次编辑 xml 文件的时间