标签:
namespace LBI.DataBinding { /// <summary> /// 可用于自身或导航至 Frame 内部的空白页。 /// </summary> public sealed partial class DataBinding2 : Page { public MainData MainDataViewModel { get; set; } public DataBinding2() { MainDataViewModel = new MainData(); this.InitializeComponent(); } private void BtnAdd_OnClick(object sender, RoutedEventArgs e) { MainDataViewModel.Result = MainDataViewModel.Num1 + MainDataViewModel.Num2; } } public class MainData : INotifyPropertyChanged { private double num1; public double Num1 { get { return num1; } set { num1 = value; OnPropertyChanged(); } } private double num2; public double Num2 { get { return num2; } set { num2 = value; OnPropertyChanged(); } } private double result; public double Result { get { return result; } set { result = value; OnPropertyChanged(); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } }
标签:
原文地址:http://www.cnblogs.com/liubiao/p/5159539.html