zoukankan      html  css  js  c++  java
  • UWP--MVVM简单计算器

    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));
                }
            }
        }
    }
    
  • 相关阅读:
    总结
    webview细节注意
    对图片的处理
    介绍并提高app中WebView的性能
    工作中新接触的问题
    iOS环信
    Framework静态库制作方法
    多线程GCD
    iOS开发之地图与定位
    ARC内存管理机制详解
  • 原文地址:https://www.cnblogs.com/liubiao/p/5159539.html
Copyright © 2011-2022 走看看