项目使用MVVM,创建了一个基类VMBase
using System.ComponentModel; using System.Runtime.CompilerServices; namespace YKCore.ViewModels { public class VMBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged([CallerMemberName] string propertyName = "") { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }
然后创建继承类的时候,要写一个属性,比较麻烦
private Visibility _BtnOKV; public Visibility BtnOKV { get=>_BtnOKV; set { _BtnOKV=value; RaisePropertyChanged(); } }
折腾了一会文本模板发现不错,比如下面的代码,就能自动生成一个类,效率还是蛮高的!
using System; using System.Windows; using System.Windows.Media; namespace YKCore.ViewModels { public class VMMessageBox : VMBase { public VMCommand Commands{get;set;} } }
Copyright © 2004-2024 Ynicp.com 版权所有 法律顾问:建纬(昆明)律师事务所 昆明市网翼通科技有限公司 滇ICP备08002592号-4