码迷,mamicode.com
首页 > Windows程序 > 详细

WPF customize DelegateCommand

时间:2019-11-24 17:19:21      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:cut   sys   view   span   his   ons   string   app   pac   

using 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

标签:cut   sys   view   span   his   ons   string   app   pac   

原文地址:https://www.cnblogs.com/Fred1987/p/11923135.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!