简体   繁体   English

UWP - 带网格的矩阵

[英]UWP - Matrix With Grid

I first would like to say that I am fairly new to UWP, and my experience with Android is probably leading some some assumptions on my end.我首先想说的是,我对 UWP 还很陌生,而我对 Android 的经验可能会导致我的一些假设。 There may be a better way about this, but so far I have been trying to use the Grid class, but it doesn't seem to work in a way that I would expect.对此可能有更好的方法,但到目前为止,我一直在尝试使用 Grid class,但它似乎并没有以我期望的方式工作。

Basic Idea基本理念

I am trying to create a UWP application with the ability of organizing elements in a matrix, where each row and column represents some category, and whatever element that is within both row and column categories is placed in that cell.我正在尝试创建一个 UWP 应用程序,该应用程序能够在矩阵中组织元素,其中每一行和每一列都代表某个类别,并且在行和列类别中的任何元素都放置在该单元格中。 One or more elements can be listed in each matrix coordinate.每个矩阵坐标中可以列出一个或多个元素。 An image for reference is below:供参考的图像如下:

一般矩阵设计

To give a more clearer/specific example, let's say the Elements were Employees, rows were Teams, and columns were disciplines (Testing, Dev, Management)举一个更清晰/具体的例子,假设元素是员工,行是团队,列是学科(测试、开发、管理)

前任。团队 X 纪律

Comparing different category-types can be useful for displaying information, but this will have greater importance beyond just names, so this is only a simplified example.比较不同的类别类型对于显示信息可能很有用,但这将比名称更重要,因此这只是一个简化的示例。 Also, as shown in the example, the number of rows and columns is determined by the number of categories there are for each respectively (eg # rows = # teams and # columns = # disciplines).此外,如示例中所示,行数和列数分别由每个类别的数量确定(例如,# 行 = # 团队和 # 列 = # 学科)。

I don't have any code to show, simply because this isn't so much an error problem as it is a conceptual problem.我没有任何代码要显示,仅仅是因为这不是一个错误问题,而是一个概念问题。

My Questions我的问题

  • How would I be able to filter what elements are bound to a cell by their Row/Column?我如何能够通过行/列过滤哪些元素绑定到单元格? Is this even possible?这甚至可能吗?
    • ie populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.即用占据相应行和列类别的元素填充矩阵的单元格。
  • How do I bind columns and rows to their respective list of categories?如何将列和行绑定到它们各自的类别列表?
    • eg whenever I add another Column Category, a new empty column will be generated.例如,每当我添加另一个列类别时,都会生成一个新的空列。

I appreciate your help and time!感谢您的帮助和时间!

For your scenario, the better way is using DataGrid to replace.对于您的方案,更好的方法是使用DataGrid替换。

ie populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.即用占据相应行和列类别的元素填充矩阵的单元格。

You could use binding way to specific current element in which column and row, but you need to calculate before preparing data source for Grid panel.您可以使用绑定方式绑定到特定当前元素的列和行,但您需要在为 Grid 面板准备数据源之前进行计算。

whenever I add another Column Category, a new empty column will be generated.每当我添加另一个列类别时,都会生成一个新的空列。

If you use DataGrid , it will generate Column base on your item's new filed.如果您使用DataGrid ,它将根据您的项目的新文件生成 Column Here is code sample that your could refer.这是您可以参考的代码示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM