tags:

views:

37

answers:

2

In our product, we use MVVM model first approach and it works nicely but with one caveat. When view becomes complex it takes time to create it from the data template. If the view is shown and hidden frequently, it becomes slightly irritating. If using view first, it would be easy enough to cache a view if needed - but when using DataTemplate and model first, we do not have much control of view creation. Anybody solved this problem already without switching to the view first method?

+1  A: 

hi, with viewmodel first approach i think you have no chance to "cache" the view. so you may consider to use view first and a viewmodel locator for the heavyweight datatemplates workflows. here is a solution when using datatemplates with lists.

but maybe there is any solution with overriding the wpf datatemplate mechanism?

edit: what if you create just a "markerview" for your viewmodel, so wpf datatemplate can find it. and then within this marker view you create/rehydrate the real view? something like an view service locator?

blindmeis
Neat idea on the "markerview", I'll see if it works...
Sergey Aldoukhov
let me know if it works ;)
blindmeis