Search code examples
wpfperformancedatagriddrawtimeline

Fast lightweight method to draw in DataGrid


I need some kind of timeline in a "datagrid" and the character has quite a few lines.

https://www.dropbox.com/s/idz0zuk8u3jla11/img.PNG?m

The left side of my datagrid works very well because there is only text.

The right side is a little bit laggy.

Actually, I have my DataGridTemplateColumn at the first index of the timeline part.

My DataGridTemplateColumn uses my UserControl as DataTemplate, where I have drawn my lines/rectangles for the entire line. This works because I set the left margin of the objects as example 500 so it appears over the other columns at the right side...

The usercontrol is a simple grid where I have placed my rectangles dynamically.

Other columns are also DataGridTemplateColumn but they are empty.

Now, my idea is to make only a single column where I can place a large usercontrol and that draws the timeline for the line.

What is the best practice to do that?

thanks


Solution

  • I have seen that you want to make a Time Line, that is great. I think that maybe a Grid is not the best panel for doing this. I think that for this case you should to implement your own custom panel. Making a custom panel is great, because you may to set how the items will be showed and also you may add animations or drag behaviors. You can see this pages :

    Also I attached some panel links that I have found, take a look, maybe you can find useful things.

    EDIT


    Another thing I forgot, you can set in any ItemsControl the property ItemsPanel, in this way you can use your panel with any items source, you can use it for instance in a ListBox.