I have a usercontrol in a content pane. If I use mvvm datatemplate to create my view:
<DataTemplate DataType="{x:Type platevm:PlateViewModel}" >
<plate:PlateView />
</DataTemplate>
The view is instantiated twice if in a content pane. So:
Thanks for the response Alex.
I will try to set the ContentPane style as you suggest, because each content pane in my app needs to display one usercontrol, like the plate view.
I dont want to set the plate view element directly in the content pane because then I lose access to the ViewModel properties in the xaml- and I would prefer to keep them in the viewmodel than the view along mvvm lines.
I am a little confused as to the difference between setting the ContentPane style for the data template and just using a data template like I was doing, it would be much appreciated if you could explain a bit!
Thanks!
Hello,
I think the problem is coming from the incorrect usage of the DataTemplate.
If you want each ContentPane to use this DataTemplate for its Content, then you should create a style for the ContentPane and set this DataTemplate to the ContentTemplate property.
If you want a ContentPane to have a PlateView element for its content, then you should put a PlateView element as direct content.
*bump*
This is killing my app, 10 days no response?