当前位置: 首页 > news >正文

科技网站制作推广app怎么做

科技网站制作,推广app怎么做,开发工程师,兰州做网站价格文章目录 前言ToolkitNuget安装简单使用SetProperty#xff0c;通知更新RealyCommandCanExecute 新功能#xff0c;代码生成器ObservablePropertyNotifyCanExecuteChangedForRelayCommand其他功能对应关系 NotifyPropertyChangedFor 前言 CommunityToolkit.Mvvm#xff08;… 文章目录 前言ToolkitNuget安装简单使用SetProperty通知更新RealyCommandCanExecute 新功能代码生成器ObservablePropertyNotifyCanExecuteChangedForRelayCommand其他功能对应关系 NotifyPropertyChangedFor 前言 CommunityToolkit.Mvvm以下简称Toolkit是WPF最有名的两个框架一个是Prism另一个就是Toolkit。 Prism可以看我的Prism详解 WPF Prims框架详解 Toolkit Toolkit 官方文档 用 CommunityToolkit.Mvvm 加速 MVVM 开发流程 Nuget安装 简单使用 Toolkit简单复写了我们常用的两个方法 一个是 SetProperty一个是RelayCommand SetProperty通知更新 public class MainViewModel:ObservableObject{private string _title;public string Title{get _title;set SetProperty(ref _title,value);}}RealyCommand public RelayCommand ButtonClickCommand { get; set; }public MainViewModel() {ButtonClickCommand new RelayCommand(() { Debug.WriteLine(Hello World!); });}MVVM模式的3种command总结[2]–RelayCommand RealyCommand主要有一个CanExecute属性。通知是否能点击 CanExecute 通知按钮能否点击我感觉有点鸡肋 public class MainViewModel:ObservableObject {private string _title Hello world!;public string Title{get _title;set SetProperty(ref _title,value);}private bool _isEnable false;public bool IsEnable{get _isEnable;set{SetProperty(ref _isEnable,value);ButtonClickCommand.NotifyCanExecuteChanged();}}public RelayCommand ButtonClickCommand { get; set; }public MainViewModel(){ButtonClickCommand new RelayCommand(() { Title Value is changed; },()IsEnable);} }Window.DataContextviewModel:MainViewModel / /Window.DataContext GridStackPanel HorizontalAlignmentCenter VerticalAlignmentCenter TextBox Text{Binding Title} Width200/CheckBox ContentIs Enable IsChecked{Binding IsEnable} /Separator Margin5/Button Command{Binding ButtonClickCommand} ContentClick Me//StackPanel /Grid新功能代码生成器 Toolkit新增了生成器功能自动帮我们将代码补全。 ObservableProperty ObservableProperty 生成的Public属性是符合一下特性 private nameName_nameNamem_nameName 以上三者都会自动对应到public Name NotifyCanExecuteChangedFor 因为我们之前修改RelayCommand的CanExecute都是通过public 里面的get set去通知的我们现在可以使用NotifyCanExecuteChangedFor来通知 [NotifyCanExecuteChangedFor(nameof(ButtonClickCommand))] [ObservableProperty] private bool _isEnable false; //等价于 private bool _isEnable false;public bool IsEnable{get _isEnable;set{SetProperty(ref _isEnable,value);ButtonClickCommand.NotifyCanExecuteChanged();}} RelayCommand RelayCommand给一个Void函数会自动生成一个对应Command 和初始化这个Command [RelayCommand] public void ButtonClick() {} //等价于 public RelayCommand ButtonClickCommand { get; set; }public MainViewModel() {ButtonClickCommand new RelayCommand(() { Title Value is changed; }, () IsEnable);} 其他功能 //将CanExecute绑定到IsEnable [RelayCommand(CanExecute nameof(IsEnable))] public void ButtonClick() {} ///异步函数也可以CanExecute会在异步函数结束之后变回去 [RelayCommand(CanExecute nameof(IsEnable))] public async Task ButtonClickAsync() {await Task.Delay(1000);Title 我被修改了; }异步函数演示注意看按钮颜色 对应关系 ButtonClickAsync、ButtonClickButtonClickCommand NotifyPropertyChangedFor 我们希望两个属性是强关联的比如Title和TestStr是强关联的。 我们希望能通知另一个属性发生了更改比如Title 通知TestStr更改 private string testStr $Title:{Title};但是这么写会报错只能设置静态方法 然后我们可以通过NotifyPropertyChangedFor来进行通知 [ObservableProperty] [NotifyPropertyChangedFor(nameof(TestStr))] private string _title Hello world!;public string TestStr $Title:{Title};
http://www.hkea.cn/news/14299478/

相关文章:

  • 北京工程建设信息网站上海备案证查询网站查询网站查询系统
  • 现在流行什么做网站wordpress教程 ppt
  • 茂名营销网站开发做网站的步骤是什么
  • 苏州微网站制作网站布局 种类
  • 弄个做网站公司上市装修公司排名前十强
  • 太平洋网站建设中国建设项目招标网站
  • 温州网站建设团队弄一个微信小程序多少钱
  • 可以购买网站空间的网站网站做广告的好处
  • 网站建设公司圣辉友联黑马程序员上海校区
  • 上市公司网站建设要求重庆石桥铺网站建设公司
  • 织梦网站栏目不能更新同步wordpress文章
  • 朝阳网站建设电信网络服务商
  • 旅游信息网站开发背景云南网站备案
  • 电商类网站开发项目流程软文营销的特点有哪些
  • 网站做一个多少钱app开发公司公司
  • 做网站的参考文献有哪些软件项目管理项目计划书
  • 能自己做网站吗网站开发要注意安全性
  • 香奈儿网站建设智慧校园网络建设方案
  • 自己的网站怎么建立互联网保险公司有哪些
  • 铜陵做网站网站页面制作公司
  • 有哪些程序做的网站迅雷2t免费空间活动
  • 成都网站设计报价服务器建设一个自己的网站
  • 网站开发外包公司快速开发工具网站
  • 合肥市门窗工程在哪个网站接活做品牌活动策划方案
  • 中国优秀设计网站wordpress必装的插件
  • 网站怎么做外部优化中信建设有限责任公司董事长
  • 网站后台安全性陕西省安康市建行 网站
  • 想再算命网站上登广告怎么做江阴网站网站建设
  • 卖网站赚钱免费下载微信
  • 织梦网站登录朔州网站设计公司