private decimal depositTotal; > > public decimal DepositTotal > { > get > { > return this.depositTotal; > } > > set > { > if (value != this.depositTotal) > { > this.depositTotal = value; > this.OnPropertyChanged("DepositTotal"); > } > } > } > > private decimal balanceOutstanding; > > public decimal BalanceOutstanding > { > get > { > return this.balanceOutstanding; > } > > set > { > if (value != this.balanceOutstanding) > { > this.balanceOutstanding = value; > this.OnPropertyChanged("BalanceOutstanding"); > } > } > }>
<TextBox Name="txtDepositTotal" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DepositTotal}"/>>
<TextBox Name="txtBalanceOutstanding"Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=BalanceOutstanding}" />>
<TextBox Text="{Binding dep_amount, Mode=Default}" > Name="txtDep_Amount" > VerticalAlignment="Center" />>
public decimal DepositTotal { get { return this.depositTotal; } set { if (value != this.depositTotal) { this.depositTotal = value; this.MyDepositTotalChangedDoSomething(); this.OnPropertyChanged("DepositTotal"); } } }or, you can trap the propertychanged event and do it there...
this.OnPropertyChanged += PropertyChangedDoSomethign());
then in the handler:private void PropertyChangedDoSomething(object sender, RoutedEventArgs e) { if(e.Property.Equals("DepositTotal") { do something here.... } }if the property definition and the code are in the same windows, then I prefer to just modify the property definition ala the first example. If they are spread across different code behinds, then example 2.