Performance problem with DataGrid and RowDetailsTemplate

Oct 28, 2011 at 10:12 AM

In my application I use a DataGrid to display a collection of objects. For this object type I have created a View and ViewModel. When I select a row I want to show the user this view by setting the RowDetailsTemplate. It works but it can take a long time before the view is shown. When I set the property SupportParentViewModelContainers to false this resolves this issue, but I'm not sure if this the only way and correct way to solve it problem. 

I've included the log, which shows that the search can take more then 600ms:

10:56:13:274 => [DEBUG] [Catel.MVVM.UI.ControlToViewModelMappingHelper] Initialized view model container to manage ControlToViewModel mappings
10:56:13:275 => [DEBUG] [Catel.Data.ObservableObject] Skipping the search for an instance of the InfoBarMessageControl
10:56:13:927 => [DEBUG] [Catel.Data.ObservableObject] Couldn't find parent view model container

Oct 28, 2011 at 2:24 PM

Catel supports a tree of view models. This means that if a view model at a top level is saved, all child view models are automatically saved as well. This comes in very handy when using nested user controls (then you normally want to save all the view models). However, sometimes there simply is no parent view model, but Catel still searches the visual tree to find the parent view model container (all Catel controls implement IViewModelContainer so the ViewModel can be retrieved). In such a case, the search in the visual tree can take a while, and in such cases it is best to simply set the SupportParentViewModelContainers to false.

Another option that can improve performance is the SkipSearchingForInfoBarMessageControl. Catel also searches for the InfoBarMessageControl. This is to prevent that multiple InfoBarMessageControl elements are added by Catel. If you don't have or don't wish to use the InfoBarMessageControl, simply set the property to true.