• 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));
                }
            }
        }
    }
    
  • 相关阅读:
    对象流(序列化,反序列化)
    随机存取文件流(双性流)
    网络编程
    ByteArrayOutputStream小测试
    Java基础
    IO流实现GBK写入文件然后转换UTF-8
    IO流实现简单的文件的剪切
    递归
    ZKDQ--问题整理
    postman测试上传文件接口
  • 原文地址:https://www.cnblogs.com/liubiao/p/5159539.html
Copyright © 2020-2023  润新知