Get TextBox Value in ViewModel
<p>Anyone one please tell me with example ,how to get textbox value in View Model, My model property is already Binding with textbox with Mode Two Way</p>

<p><a href="https://i.stack.imgur.com/AbVyq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AbVyq.jpg" alt="enter image description here"></a></p>

<p>This is my view model functions, I want to add new record to my observable collection.</p>

<p>C#</p>

<pre><code>public void AddPerson()
{
  // add new record
}

private Model.Person _PersonData;
public Model.Person PersonData
{
    get {
        if(_PersonData==null)
        {
            _PersonData = new Person();
        }
        return _PersonData;
        }
    set
    {
        Setproperty(ref this._PersonData, value);
    }
}
</code></pre>

<p>XAML</p>

<pre><code>&lt;Controls:MetroWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:VM="clr-namespace:Demo.ViewModel"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Model="clr-namespace:Demo.Model" mc:Ignorable="d" x:Class="Demo.MainWindow"
    Title="MainWindow" Height="438" Width="664"
    GlowBrush="{DynamicResource AccentColorBrush}"              
    WindowStartupLocation="CenterScreen"&gt;
&lt;Controls:MetroWindow.Resources&gt;
    &lt;Model:Person x:Key="PersonDataSource" d:IsDataSource="True"/&gt;
    &lt;VM:MainViewModel x:Key="MainViewModelDataSource" d:IsDataSource="True"/&gt;
&lt;/Controls:MetroWindow.Resources&gt;

   &lt;Controls:MetroWindow.RightWindowCommands&gt;
    &lt;Controls:WindowCommands&gt;
        &lt;!--&lt;Button Content="settings" /&gt;--&gt;
        &lt;Button&gt;
            &lt;StackPanel Orientation="Horizontal"&gt;
                &lt;Rectangle Width="20"
               Height="20"
               Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"&gt;
                    &lt;Rectangle.OpacityMask&gt;
                        &lt;VisualBrush Stretch="Fill" Visual="{StaticResource appbar_futurama_fry}" /&gt;
                    &lt;/Rectangle.OpacityMask&gt;
                &lt;/Rectangle&gt;
                &lt;TextBlock Margin="4 0 0 0"
               VerticalAlignment="Center"
               Text="Karthik" /&gt;
            &lt;/StackPanel&gt;
        &lt;/Button&gt;
    &lt;/Controls:WindowCommands&gt;
&lt;/Controls:MetroWindow.RightWindowCommands&gt;


&lt;Grid DataContext="{Binding Source={StaticResource MainViewModelDataSource}}"&gt;
    &lt;Grid.Background&gt;
        &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
            &lt;GradientStop Color="#FFF3F3F3" Offset="0"/&gt;
            &lt;GradientStop Color="#FFFBF9F9" Offset="1"/&gt;
            &lt;GradientStop Color="#FFF7F6F6" Offset="0.555"/&gt;
        &lt;/LinearGradientBrush&gt;
    &lt;/Grid.Background&gt;
    &lt;Border BorderThickness="3" HorizontalAlignment="Left" Height="388" Margin="10,10,0,0" VerticalAlignment="Top" Width="636" CornerRadius="3"&gt;
        &lt;Border.Background&gt;
            &lt;LinearGradientBrush EndPoint="0.168,0.166" StartPoint="0.168,0.08"&gt;
                &lt;GradientStop Color="#FF39D5FF" Offset="0"/&gt;
                &lt;GradientStop Color="White"/&gt;
            &lt;/LinearGradientBrush&gt;
        &lt;/Border.Background&gt;
        &lt;Label Content="Master Details" Margin="10,1,502,352" FontWeight="Bold" Foreground="White"/&gt;
    &lt;/Border&gt;

    &lt;Border BorderBrush="#FFC7C2C2" BorderThickness="1" HorizontalAlignment="Left" Height="238" Margin="21,100,0,0" VerticalAlignment="Top" Width="187" CornerRadius="3"&gt;
        &lt;Border.Background&gt;
            &lt;LinearGradientBrush EndPoint="0.433,0.407" StartPoint="0.435,0.134"&gt;
                &lt;GradientStop Color="#29c5ff" Offset="0"/&gt;
                &lt;GradientStop Color="White"/&gt;
            &lt;/LinearGradientBrush&gt;
        &lt;/Border.Background&gt;
    &lt;/Border&gt;
    &lt;Border BorderBrush="#FFC7C2C2" BorderThickness="1" HorizontalAlignment="Left" Height="239" Margin="227,100,0,0" VerticalAlignment="Top" Width="405" CornerRadius="3"&gt;
        &lt;Border.Background&gt;
            &lt;LinearGradientBrush EndPoint="0.435,0.378" StartPoint="0.435,0.134"&gt;
                &lt;GradientStop Color="#29c5ff" Offset="0"/&gt;
                &lt;GradientStop Color="White"/&gt;
            &lt;/LinearGradientBrush&gt;
        &lt;/Border.Background&gt;
        &lt;Button Content="DELETE" Margin="211,189,41,21" Width="149" Height="21"/&gt;
    &lt;/Border&gt;
    &lt;Label Content="New" HorizontalAlignment="Left" Height="29" Margin="37,103,0,0" VerticalAlignment="Top" Width="87" Foreground="White"/&gt;
    &lt;Label Content="Update" HorizontalAlignment="Left" Height="25" Margin="246,105,0,0" VerticalAlignment="Top" Width="98" Foreground="White"/&gt;
    &lt;TextBox HorizontalAlignment="Left" Height="25" Margin="37,150,0,0" TextWrapping="Wrap" Text="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="149" DataContext="{Binding Source={StaticResource PersonDataSource}}"/&gt;
    &lt;TextBox HorizontalAlignment="Left" Height="19" Margin="37,197,0,0" TextWrapping="Wrap" Text="{Binding Path=ID,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="149" DataContext="{Binding Source={StaticResource PersonDataSource}}"/&gt;
    &lt;Button Content="Update" HorizontalAlignment="Left" Height="24" Margin="37,291,0,0" VerticalAlignment="Top" Width="149"/&gt;
    &lt;Button Command="{Binding _addCommand}" Content="edit" HorizontalAlignment="Left" Height="21" Margin="272,291,0,0" VerticalAlignment="Top" Width="149"/&gt;
    &lt;ListView HorizontalAlignment="Left" Height="120" Margin="246,150,0,0" VerticalAlignment="Top" Width="366"  ItemsSource="{Binding MasterData}"&gt;
        &lt;ListView.View&gt;
            &lt;GridView&gt;
                &lt;GridViewColumn  Header="Name" Width="120"&gt;
                    &lt;GridViewColumn.CellTemplate&gt;
                        &lt;DataTemplate&gt;
                            &lt;TextBlock Text="{Binding Name}" TextWrapping="Wrap"/&gt;  
                        &lt;/DataTemplate&gt;   
                    &lt;/GridViewColumn.CellTemplate&gt;    
                &lt;/GridViewColumn&gt;
                &lt;GridViewColumn Header="ID" Width="120"&gt;
                    &lt;GridViewColumn.CellTemplate&gt;
                        &lt;DataTemplate&gt;
                            &lt;TextBlock Text="{Binding ID}" TextWrapping="Wrap"/&gt;
                        &lt;/DataTemplate&gt;
                    &lt;/GridViewColumn.CellTemplate&gt;
                &lt;/GridViewColumn&gt;
                &lt;GridViewColumn Header="Location" Width="125"&gt;
                    &lt;GridViewColumn.CellTemplate&gt;
                        &lt;DataTemplate&gt;
                            &lt;TextBlock Text="{Binding Location}" TextWrapping="Wrap"/&gt;
                        &lt;/DataTemplate&gt;
                    &lt;/GridViewColumn.CellTemplate&gt;
                &lt;/GridViewColumn&gt;
            &lt;/GridView&gt;
        &lt;/ListView.View&gt;
    &lt;/ListView&gt;
    &lt;TextBox HorizontalAlignment="Left" Height="19" Margin="37,241,0,0" TextWrapping="Wrap" Text="{Binding Path=Location,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="149" DataContext="{Binding Source={StaticResource PersonDataSource}}"/&gt;

&lt;/Grid&gt;
&lt;/Controls:MetroWindow&gt;
</code></pre>