Search Results

Search found 1 results on 1 pages for 'user1033098'.

Page 1/1 | 1 

  • WPF/INotifyPropertyChanged, change the value of txtA, the txtB and txtC should change automatically?

    - by user1033098
    I supposed, once i change the value of txtA, the txtB and txtC would change automatically, since i have implemented INotifyPropertyChanged for ValueA. But they were not updated on UI. txtB was always 100, and txtC was always -50. I don't know what's the reason. My Xaml.. <Window x:Class="WpfApplicationReviewDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <StackPanel> <TextBox Name="txtA" Text="{Binding ValueA}" /> <TextBox Name="txtB" Text="{Binding ValueB}" /> <TextBox Name="txtC" Text="{Binding ValueC}" /> </StackPanel> </Window> My code behind... public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.DataContext = new Model(); } } public class Model : INotifyPropertyChanged { private decimal valueA; public decimal ValueA { get { return valueA; } set { valueA = value; PropertyChanged(this, new PropertyChangedEventArgs("ValueA")); } } private decimal valueB; public decimal ValueB { get { valueB = ValueA + 100; return valueB; } set { valueB = value; PropertyChanged(this, new PropertyChangedEventArgs("ValueB")); } } private decimal valueC; public decimal ValueC { get { valueC = ValueA - 50; return valueC; } set { valueC = value; PropertyChanged(this, new PropertyChangedEventArgs("ValueC")); } } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; #endregion } After i add code to the set method of ValueA property, it works. public decimal ValueA { get { return valueA; } set { valueA = value; PropertyChanged(this, new PropertyChangedEventArgs("ValueA")); PropertyChanged(this, new PropertyChangedEventArgs("ValueB")); PropertyChanged(this, new PropertyChangedEventArgs("ValueC")); } } But I supposed it should be automatically refresh/updated for txtB and txtC. Please advise.

    Read the article

1