title: Wpf Prism - Passing parameter from view to viewmodel
body: <p>I created a view (MyView) where I included a UserControl like this:</p>
  
  <pre><code>&lt;StackPanel&gt;
    &lt;ctrl:ViewDialog DataContext="{Binding CtrlViewDialog}" Message="Hello" Name="ctrlViewDialog" &gt;                     
  &lt;/ctrl:ViewDialog&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code behind of the view:</p>
  
  <pre><code>public MyView()
          {
              InitializeComponent();
              var _message = ctrlViewDialog.Message;
          }
  
          [Dependency]
          public MyViewViewModel ViewModel
          {
              get
              {
                  return (MyViewViewModel)this.DataContext;
              }
              set
              {
  
                  this.DataContext = value;
              }
          }
  </code></pre>
  
  <p>and the view model MyViewViewModel is:</p>
  
  <pre><code>public MyViewViewModel()
          {         
  
              ViewDialogViewModel CtrlViewDialog = new ViewDialogViewModel(Message);
          }
  </code></pre>
  
  <p>The code behind of the included UserControl (ViewDialog) is:</p>
  
  <pre><code>private string message;
          public string Message
          {
              get { return message; }
              set { message = value; }
          }
  
  
          public ViewDialog()
          {
              InitializeComponent();
          }
  </code></pre>
  
  <p>How could I pass the <code>"_message"</code> parameter of MyView to MyViewViewModel in order to pass it to the instance <code>ViewDialogViewModel CtrlViewDialog = new ViewDialogViewModel(Message);</code></p>