0

Based on this mechanism, I created a dialog window of which I can dynamically assign the content by a <ContentPresenter Content="{Binding .}"> The content I want to assign is an user control with a corresponding ViewModel. This works as I can render the DialogView in other usercontrols

<DataTemplate DataType="{x:Type ViewModels:DialogViewModel}"> <Views:DialogView/> </DataTemplate> )

However, in the DialogWindow, DialogView cannot be rendered but instead, only the string representation of DialogViewModel is visible. What might be the reason why I cannot render the view of contentpresenter's content?

Any help is much appreciated!

Thanks in advance

Community
  • 1
  • 1

1 Answers1

0

Where did you define the Data Template? It sounds like you are creating them as Window resources, and did not include it in your DialogWindow. If you're defining them as Window resources, the Data Template definition needs to be included on every Window you want to render this way. If the ViewModel/View pair is global to the application, it is easier to just define it in the App.xaml where it will be picked up by any Window or UserControl throughout the application.

  • Thanks so much Chris, you are right, I defined it not in the App.xaml but in the main window and WindowDialog did not see it as it is in a different namespace. It was a stupid mistake and you saved my time! – user6224868 Apr 20 '16 at 03:07