Search code examples
c#user-interfacedata-bindinguwp

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

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. One or more elements can be listed in each matrix coordinate. An image for reference is below:

General Matrix Design

To give a more clearer/specific example, let's say the Elements were Employees, rows were Teams, and columns were disciplines (Testing, Dev, Management)

Ex. Teams X Discipline

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 (e.g. # 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?
    • i.e. 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?
    • e.g. whenever I add another Column Category, a new empty column will be generated.

I appreciate your help and time!


Solution

  • For your scenario, the better way is using DataGrid to replace.

    i.e. 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.

    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. Here is code sample that your could refer.