如何在 listView 的末尾添加按钮? [英] How can I add a button at the end of a listView?

查看:39
本文介绍了如何在 listView 的末尾添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以与 bing 应用程序相同的方式在 listView 的末尾添加一个按钮(例如参见图片).

Iwould like to add a button at the end of a listView in the same way as the bing apps do (see picture for example).

我在谷歌和微软文档中找了几个小时,但找不到任何可以让我知道如何做到这一点的东西.

I looked for hours in google and in the microsoft documentation but canøt find anything that can give me an idea of how to do this.

有人做到了吗?

谢谢

推荐答案

如果您运行该应用 (Health & Fitness),然后运行 ​​Visual Studio 并使用调试">附加到进程",您可以打开 DOM 资源管理器并检查如何该 UI 已实现.

If you run that app (Health & Fitness), then run Visual Studio and use Debug > Attach to Process, you can open the DOM Explorer and examine how that UI is implemented.

在这种情况下,您将看到它根本不使用 ListView,而是它自己的自定义控件,它仅基于 CSS 网格.也就是说,仅仅因为有一个类似网格的视图并不意味着它是一个 ListView.你总是可以使用直接的 HTML/CSS 布局来实现这些事情,这就是这里发生的一切.因此,它只是为这两个更多"元素制作单独的 div.

What you'll see in this case is that it's not using a ListView at all, but rather it's own custom control that's just based on a CSS grid. That is, just because there's a grid-like view doesn't mean it's a ListView. You can always use straight HTML/CSS layout to achieve these sorts of things, which is all that's happening here. As such, it just makes separate div's for those two "More" elements.

现在,如果您确实想要使用 ListView,那么您可以做一些事情.首先,如果您想以不同于其他方式呈现 ListView 中的任何项目,您必须确保使用不同的模板.这意味着您使用项目呈现函数而不是声明性模板,然后您可以检查项目数据并以编程方式决定要执行的呈现类型.

Now if you do want to use a ListView, there are a few things you can do. First of all, if you want to render any item in a ListView differently than others, you have to make sure to use a different template. What this means is that you use an item rendering function rather than a declarative template, which then enables you to examine the item data and programmatically decide what kind of rendering to perform.

其次,如果你想拥有不同大小的items,那么你需要使用cell spanning.在 Windows 8.0/WinJS 1.0 中,这是 GridLayout 的一个属性.在 Windows 8.1/WinJS 2.0 中,您可以使用 CellSpanningLayout.

Second, if you want to have items of different sizes, then you need to use cell spanning. In Windows 8.0/WinJS 1.0 this is a property of the GridLayout. In Windows 8.1/WinJS 2.0 you instead use the CellSpanningLayout.

我在 第二版预览的第 7 章中详细介绍了渲染功能和单元格跨度使用 HTML、CSS 和 JavaScript 编写 Windows 应用商店应用程序,这是 Microsoft Press 提供的免费电子书,因此您无需支付任何费用.:)

I have all the details for both rending functions and cell spanning written up in Chapter 7 of my second edition preview of Programming Windows Store Apps with HTML, CSS, and JavaScript, which is a free ebook from Microsoft Press so it doesn't cost you anything. :)

这篇关于如何在 listView 的末尾添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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