title: DataBinding with read-only property
body: <p>I have a view that allows the user to enter a payment amount, then optionally enter principal, interest, and escrow amounts.</p>
  
  <p>Everything is good with those four <code>TextBox</code>es using <code>TwoWay</code> databinding like so:</p>
  
  <pre><code>&lt;TextBlock Grid.Row="3"
             Grid.Column="0"
             Text="Payment Amount" /&gt;
  &lt;TextBox Grid.Row="3"
           Grid.Column="1"
           Text="{x:Bind ViewModel.CurrentPayment.PaymentAmount, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:N}', Mode=TwoWay}" /&gt;
  &lt;TextBlock Grid.Row="4"
             Grid.Column="0"
             Text="Principal" /&gt;
  &lt;TextBox Grid.Row="4"
           Grid.Column="1"
           Width="100" Text="{x:Bind ViewModel.CurrentPayment.PrincipalAmount, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:N}', Mode=TwoWay}" /&gt;
  &lt;TextBlock Grid.Row="5"
             Grid.Column="0"
             Text="Interest" /&gt;
  &lt;TextBox Grid.Row="5"
           Grid.Column="1"
           Width="100"
           MaxLength="20"
           Text="{x:Bind ViewModel.CurrentPayment.InterestAmount, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:N}', Mode=TwoWay}" /&gt;
  &lt;TextBlock Grid.Row="6"
             Grid.Column="0"
             Text="Escrow" /&gt;
  &lt;TextBox Grid.Row="6"
           Grid.Column="1"
           Width="100"
           MaxLength="20"
           Text="{x:Bind ViewModel.CurrentPayment.EscrowAmount, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:N}', Mode=TwoWay}" /&gt;
  </code></pre>
  
  <p>However, when I try to add a "summary" property called <code>TotalAmount</code> that takes the total of <code>PrincipalAmount</code>+<code>InterestAmount</code>+<code>EscrowAmount</code> as shown here:</p>
  
  <pre><code>[JsonIgnore]
  public decimal TotalAmount
  {
      get
      {
          var amount = EscrowAmount + InterestAmount + PrincipalAmount;
          return amount;
      }
  }
  </code></pre>
  
  <p>My property does not update if the user makes changes to the <code>TextBox</code> for principal/interest/escrow amounts. The <code>TotalAmount</code> displays correctly when loading the view, but does not update when the values change. Here is the XAML for the <code>TextBlock</code>:</p>
  
  <pre><code>&lt;TextBlock Text="{x:Bind ViewModel.CurrentPayment.TotalAmount, Converter={StaticResource StringFormatConverter}, ConverterParameter='{}{0:N}'}" /&gt;
  </code></pre>
  
  <p>Is there a way to let the <code>TotalAmount</code> property know when one of the other properties' value changes, so it can update the displayed value?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Adding the other three property definitions to show use of <code>INotifyPropertyChanged</code>.</p>
  
  <pre><code>private decimal _principalAmount;
  [JsonProperty("principalamount")]
  public decimal PrincipalAmount
  {
      get { return _principalAmount; }
      set { Set(ref _principalAmount, value); }
  }
  
  private decimal _escrowAmount;
  [JsonProperty("escrowamount")]
  public decimal EscrowAmount
  {
      get { return _escrowAmount; }
      set { Set(ref _escrowAmount, value); }
  }
  
  private decimal _interestAmount;
  [JsonProperty("interestamount")]
  public decimal InterestAmount
  {
      get { return _interestAmount; }
      set { Set(ref _interestAmount, value); }
  }
  </code></pre>
  
  <p><code>Set</code> is a method from Template 10's <code>BindableBase</code>:</p>
  
  <pre><code>public abstract class BindableBase : IBindable, INotifyPropertyChanged
  {
      protected BindableBase();
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      public virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null);
      public virtual void RaisePropertyChanged&lt;T&gt;(Expression&lt;Func&lt;T&gt;&gt; propertyExpression);
      public virtual bool Set&lt;T&gt;(ref T storage, T value, [CallerMemberName] string propertyName = null);
      public virtual bool Set&lt;T&gt;(Expression&lt;Func&lt;T&gt;&gt; propertyExpression, ref T field, T newValue);
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>The main issue I was having was due to the different behavior of compiled bindings. The default <code>Mode</code> is <code>OneTime</code>, which is different from the standard binding default of <code>OneWay</code>. Once I raised the property change notifications to the <code>TotalValue</code> property, I still had to change the binding mode to <code>OneWay</code> to get my UI to update.</p>
  
  <p>More information about standard bindings and compiled bindings can be found at <a href="https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/x-bind-markup-extension" rel="nofollow noreferrer">x:Bind markup extension</a></p>