WPF customize DelegateCommand
2021-01-27 21:12
标签:cut sys view span his ons string app pac WPF customize DelegateCommand 标签:cut sys view span his ons string app pac 原文地址:https://www.cnblogs.com/Fred1987/p/11923135.htmlusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace WpfApp55.ViewModel
{
public class VM : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propName)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propName));
}
}
private DelegateCommand UCCmdValue;
public DelegateCommand UCCmd
{
get
{
if(UCCmdValue==null)
{
UCCmdValue = new DelegateCommand(UCCmdExecuted, UCCmdCanExecute);
}
return UCCmdValue;
}
}
private bool UCCmdCanExecute(object obj)
{
return true;
}
private void UCCmdExecuted(object obj)
{
MessageBox.Show("You had clicked the customized button!");
}
}
}
文章标题:WPF customize DelegateCommand
文章链接:http://soscw.com/index.php/essay/47916.html