DataGrid是UWP的替代方案吗? [英] Is DataGrid an alternative for UWP?

查看:113
本文介绍了DataGrid是UWP的替代方案吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个UWP应用程序,该应用程序应在PC和平板电脑上使用,并在以后的手机上以精简版使用。

I'm developing a UWP app that is supposed to be used on PC and Tablets and in a lite version later on mobiles.

在我想提供的PC上在移动设备上,我打算将两列中的数据隐藏起来(或者我将创建一个不同的页面),具体取决于用户的操作。

On PCs I want to provide data in two columns, on mobile I intend to hide one of them (or I'll create a different page), depending to the user's actions.

我需要的功能是;数据绑定到 List< T> (或任何相等值),以进行过滤,排序(不重要)和选择项目,就像我之前使用Datagrid所做的那样。

Functionalities I need are; databinding to a List<T>(or anything equal), to filter, sort(not important) and select items, like I did before with the Datagrid.

所选项目的值应显示为在两个文本框中进行编辑,因此我需要类似 selectedItem 属性的内容。内容也不是静态的,因为我需要能够添加和删除项目。

Values of the selected item should be shown to be edited in two textboxes, so I need something like the selectedItem property. Also the content is not static since I need to be able to add and delete items.

有什么我可以使用的东西吗?

Is there anything that I can use for this?

我已经想到要使用两个列表视图,但是我想滚动将无法正常工作。

I already had in my mind to use two list views, but I guess scrolling will not work properly.

public class Items
{
   public Int32 id;
   public String name;
   public String name2;
}

List<Items> Test = new List<Items>();


推荐答案

我需要将数据绑定到列表(或相等的内容),以进行过滤,排序(不重要)并选择项目

据我所知,UWP中没有内置的DataGrid控件。如果要将数据显示为表格,则必须自己完成。例如,您可以使用ListView和GridView,自定义其ItemTemplate使其看起来像DataGrid。这是 列表视图和网格视图指南的良好起点

As far as I know, there’s no build-in DataGrid control in UWP. If you want to show your data as a table, you would have to do it by yourself. For example, you could use ListView and GridView, custom its ItemTemplate to make it look like a DataGrid. It’s a good start with "Guidelines for list view and grid view".

如果您不想自己做,可以考虑使用一些开源库。您可以使用Bing搜索以下关键字: UWP DataGrid控件

If you don’t want to do it by yourself, you could think about using some opensource library. You could use Bing to search with this keyword: UWP DataGrid Control  

内容也不是静态的,因为我需要能够添加和删除项。

在UWP中,您可以使用 < a href = https://msdn.microsoft.com/en-us/library/ms668604(v=vs.110).aspx rel = nofollow> ObservableCollection 而不是列表,因为它已经实现了 INotifyPropertyChanged 接口,当您添加和删除项目时,它将进行更新UI自动。

In UWP, you could use "ObservableCollection" instead of "List", because it has implemented the INotifyPropertyChanged interface, when you add and delete items, it would update UI automatically.

这篇关于DataGrid是UWP的替代方案吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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