赞
踩
本文是wpf入门系列第五篇,面向有winform或者web前端基础的、并且也有C#基础的同学。
本文简单的介绍了 WPF 中界面绑定值得刷新问题, INotifyPropertyChanged 的作用及用法,以及对它的封装使用。其中,封装使用参考了WPF的开源框架ReactiveUI。
本文使用了 Visual Studio 2017 进行演示讲解。
wpf入门系列导航页面: https://blog.csdn.net/wf824284257/article/details/88757497
上一步: wpf入门第五篇 WPF with ECharts
https://blog.csdn.net/wf824284257/article/details/89002133
学习本文之前,推荐先学习这篇: wpf入门第二篇 MVVM与binding
https://blog.csdn.net/wf824284257/article/details/88758707
打开 VS2017,新建WPF项目,命名为 VMTest (VM是ViewModel的简称).
在解决方案资源管理器中右键点击我们的项目,选择【添加】->【类】,添加一个Person类。
将Person.cs代码替换为如下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VMTest
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
}
将MainWindow.xaml代码替换为下面代码:
<Window x:Class="VMTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。