Hello,
I have a TabGroupPane control with 8 ContePane, each ContePane have one XamDataGrid. When I switch from one Pane to another for the first time, it takes about 3 minutes to switch. Each XamDataGrid have approximately 100 rows and 50 Columns, with heavy custom styles. I suppose it's because the first time when we activate the pane, the DataGrid begins to Paint, and the rendering of visual elements has taken a lot of time. I have noticed that some other people are experiencing the same issue, and the solution proposed was to start a background thread and call "Activate" of each ContePane when launching the program to force the rendering of visual elements of each grid. This doesn't work for me for 2 reasons:
1) To update the UI thread, I have to do Invoke in the UI thread by Dispatcher, which blocks the UI actions, which is not wanted
2) Even if I call Invoke with a DispatchPriority.Background, it seems to no longer block the UI thread, but then I see that when calling "Activate" on each ContePane, the ContePane gets focus, stays focused for 3 seconds and then the next Pane gets focused, this is a too weird behavior that I can deliver to my client. I just want to force the paint on every Datagrid in the inactive Panes discretely when the client can continue to work in the active Pane. Is there a way to do it? I would highly appreciate if you can provide a sample. Thank you very much.
'It takes 3 seconds to switch panel', sorry for the mistake.
Hi pebg,
Is 3 seconds too long? I'm not sure how to make it faster since the XamDataGrid hasn't been rendered yet when you first switch to it. It has to create all it's visual elements in that instant and then measure + arrange them. Depending on how complex your styles are this can make it take longer and it has to do this for each cell that is in view. Considering this, 3 seconds seems pretty quick. If 3 seconds is too long then you might want to consider front loading the XamDataGrid rendering at application startup. You can manually call Measure() + Arrange() + UpdateLayout() on each of the grids in order to force them to create their UI elements and measure+arrange them ahead of time. This should help speed up tab switching at runtime.