MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
DialogHost Show performance issues when using datagrid
DialogHost Show is having a performance issue when switching between two dialogs that contain a DataGrid. Tested on two computers.
Steps to reproduce:
- Button A -> DialogA (first init slow)
- Button A -> DialogA (no problem, fast)
- Button B -> DialogB (lags)
- Button B -> DialogB (no problem, fast) ...
- Button A -> DialogA (lag)
- Button B -> DialogB (lag)
- Button A -> DialogA (lag)
- Button B -> DialogB (lag ...
Test Repo created here: https://github.com/stany9g/DataHostDemo
Attaching zip for historical reference. DataHostDemo-master.zip
Can confirm that I am able to replicate from the attached project. I believe the issue comes down to needing to know the target size of the content in order for the animation to work correctly. This problem gets compounded by the DataGrid wanting to know its maximum size so it can virtualize its elements.
I would suspect that a fix would involve manually measuring the control for the dialog before actually showing the dialog so that the animation can know the desired target size.
@Keboo I did a little more investigation about the suggested fix and not sure if it is the right suspect.
- I tried to remove the animation from the style, dit not help
- A little debugging where I found that the "lag" happens when
DialogContent = content;
this line lags even though the content has set the actual sizes.
@Keboo @stany9g When giving a fixed Width and Height to the parent Grid element, the lag disappears.
@stany9g You could also defer the collection loading to an async Initialize method on the dialogviewmodel and setting the ItemsSource binding IsAsync="True" on the datagrid for better decoupling of UI thread and logic.
@MichelMichels so for other UserControls need to set fixed Width and Height properties to show dialogs without any lags? Should they be equivalent to each other when need to show different dialogs?
@Erapchu as @Keboo mentioned, the lag has to do with the datagrid trying to calculate it's width and height.
My guess would be that the datagrid control has issues with virtualizing the rows when no static height is set and also a problem with rendering the columns when no static width is set.
I don't know if other controls behave like this.
Hello @MichelMichels @Keboo , has there been any progress regarding the performance issues on DialogHost startup? Can you let me know if there is any progress?
I don't know if this is a problem that's resolvable in the dialoghost control. It's a year ago that I took a look at this issue.
Thank you for answer @MichelMichels