开发者

Render of UIElement Causes App To Hang For Several Seconds

I have a WPF application - using MVVM for the design pattern.

In the Main View, there is a ContentPresenter that is bound to a property in the corresponding ViewModel. I have type-referential DataTemplate for the data type associated with that property. Essentially, based on a certain action performed by the user, the ContentPresenter will display the data from a specific data template. In the data开发者_运维技巧 template I have DevExpress' GridControl. It sucks and I hate it, but due to company standards, I have to use it. My main pain point is that it takes several noticeable seconds for the UI to render to data template because of this GridControl. Is there anything that I can do to mitigate this? I'd like to display a "please wait" progress indicator, but even that gets stuck for several seconds...

Please help.


Are you loading the data for this view async ?

If the data is not already loaded when you display the view, you could try to delay the loading until the grid is visible, the load the data and finally set the binding to the grid in codebehind, something like this:

private delegate void LoadDelegate();
this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new LoadDelegate(LoadOrders));

This will give the gui a chance to show itself before the loading starts.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜