What is table / grid management in WPF?

I am looking to display tabular data (television channels), but with options like DataGrid / UniformGrid / Table with FlowDocument / etc. I can’t understand what would be the best option. The main problems are that the cells are uneven in size, as they vary with the length of time, and I would also like to add padding between them. In addition, I only need to be able to display part of the table and allow them to scroll up / down / right to view the rest.

What would be the best WPF management option? Here is a small illustration of what I'm going to do. The white square in the upper left is what I would like to display at startup, and let them scroll the rest.

enter image description here

+7
source share
1 answer

There are several ways to do what you are trying to do here. If performance is not a problem, I would ignore virtualization and try DockPanel . The disadvantage here is that you will need to add elements to and not add them line by line.

Another option is to use two stack panels (one in each direction). This relates to the issue of adding, but requires the use of more panels.

Both of the two previous parameters require the individual elements to set their height / width.

The final option (depending on how big your grid is) will use a grid with fixed sizes of rows and columns with elements that occupy rows (using rowspan ). The disadvantage of this method is that I don’t know what a good way to create this control in xaml for unspecified row / column numbers, so you will need to create it in your code to get the required number of rows / columns.

If you have performance issues, you can try using VirtualizingStackPanel . If this still does not meet your performance requirements, you need to subclass VirtualizingPanel and configure it to meet your specific needs.

Read more about panel performance here .

I suggest trying two StackPanel methods StackPanel , then VirtualizingStackPanel method, and finally, if that doesn't work, try VirtualizingPanel

Filling is easily accomplished by setting the Margin property on each subcontroller.

Use ScrollViewer to scroll ScrollViewer

+3
source

All Articles