title: Content Dialog textbox value retrieval
body: <p>In my MVVM application for showing content dialog I have implemented ISpeechDialogService to show Content Dialog, which I have injected into Main Page View Model:</p>
  
  <pre><code> public interface ISpeechDialogService
      {
          Task&lt;ContentDialogResult&gt; ShowAsync();
          string GetText();
      }
  
      public class SpeechDialogService : ISpeechDialogService
      {
  
          private Speech contentDialog;
  
          public async Task&lt;ContentDialogResult&gt; ShowAsync()
          {
              contentDialog = new Speech();
              ContentDialogResult result = await contentDialog.ShowAsync();
              return result;
          }
  </code></pre>
  
  <p>So by pressing button on Main Page - following content dialog is being showed:</p>
  
  <p>Command:</p>
  
  <pre><code>public ICommand DictateCommand { get; set; }
  
          public async void Dictate(object obj)
          {
             var result = await _dialog.ShowAsync();
              if (result == ContentDialogResult.Primary)
              { new MessageDialog(_dialog.GetText()).ShowAsync(); }
          }
  </code></pre>
  
  <p>Content Dialog:</p>
  
  <pre><code>&lt;ContentDialog
      x:Class="UWP1.Views.Speech"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:UWP1.Views"
      xmlns:vm="using:UWP1.ViewModels"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      Title="Dictate"
      PrimaryButtonText="Accept"
      SecondaryButtonText="Cancel"
      PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
      SecondaryButtonClick="ContentDialog_SecondaryButtonClick" VerticalAlignment="Center"
      x:Name="ContentDialog"
      &gt;
      &lt;ContentDialog.DataContext&gt;
          &lt;Binding Path="SpeechViewModel" Source="{StaticResource ViewModelLocator}" /&gt;
      &lt;/ContentDialog.DataContext&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="auto"/&gt;
              &lt;RowDefinition Height="auto"/&gt;
              &lt;RowDefinition Height="auto"/&gt;
              &lt;RowDefinition Height="auto"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="150" /&gt;
              &lt;ColumnDefinition Width="150" /&gt;
          &lt;/Grid.ColumnDefinitions&gt;
              &lt;Button Margin="15" Content="Dictate" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Stretch" Command="{Binding DicateCommand}"/&gt;
          &lt;Button  Margin="15" Content="Clear Text" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding ClearDicateCommand}"/&gt;
          &lt;TextBlock Grid.Row="1" Grid.ColumnSpan="2" Text="Tap 'Dictate', and speak" FontSize="12" /&gt;
              &lt;TextBlock Margin="0 10 0 0" Grid.Row="2" Grid.ColumnSpan="2" Text="Message Dication" HorizontalAlignment="Center" FontSize="24"  /&gt;
          &lt;ScrollViewer Grid.Row="3" Grid.ColumnSpan="2" Height="300"&gt;
              &lt;TextBox x:Name="Input" Margin="5 5 5 10"  AcceptsReturn="True" Text="{Binding Comment}"  TextWrapping="Wrap" /&gt;
          &lt;/ScrollViewer&gt;
      &lt;/Grid&gt;
  &lt;/ContentDialog&gt;
  </code></pre>
  
  <p>I have created a separate view model for content dialog (which comprises message box) to bind commands for button and property to texbox.</p>
  
  <p>So currently I have Main Page with linked Main Page View Model and Content Dialog with a separate view model.</p>
  
  <p>What I need to do is to pass value from content's dialog textbox to Main Page View Model property.</p>
  
  <p>Could you please advise me the way I can achieve that?</p>