Note that there are some explanatory texts on larger screens.

plurals
  1. POModal Window with MVVM pattern
    primarykey
    data
    text
    <p>I am trying to make modal dialog window for let user know some error messages, or let user edit some values. I am using MVVM pattern, so my mainwindow has some control part and workspace part. In workspace part, i am opening viewmodels tight with datatemplate to views (defined as usercontrols). From one of these views i want to open modal dialog window. I was following this answer <a href="https://stackoverflow.com/questions/1321346/error-window-show-modal-in-mvvm-wpf/1329785#1329785">Error window show modal in MVVM WPF</a>. As described in that answer, i have implemented the DialogClass in an InvoiceViewModel. But i have problem with showing the content of the modal window. If I set the content of the window to ViewModel class, output is simple text with namespace path to that ViewModel. (ViewModel attached to the View with datatemplate.) If I set content to the View - it is working - view is showed but, i am disobeing MVVM pattern (opening View from ViewModel as ViewModel has no reference to View). </p> <pre><code> ErrorViewModel newErrorViewModel = new ErrorViewModel(); ErrorView newErrorView = new ErrorView(); DialogWindow dialogWindow = new DialogWindow(); //Not Working //dialogWindow.Content = newErrorViewModel; //Working But, breaking MVVM dialogWindow.Content = newErrorView; dialogWindow.ShowDialog(); </code></pre> <p>In ErrorView.xaml i have attached ErrorViewModel like this.</p> <pre><code>&lt;DataTemplate DataType="{x:Type vm:ErrorViewModel}"&gt; &lt;vw:ErrorView/&gt; &lt;/DataTemplate&gt; </code></pre> <p>What am i doing wrong?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload