wpf----命令(Command)

一,自定义命令:

1创建一个类的静态RoutedUICommand对象.并且在类初始化中创建该静态对象. 本实列创建了该类和类中的静态对象.

 public class DataCommands
    {
        private static RoutedUICommand requery;
        static DataCommands()
        {
            InputGestureCollection inputs = new InputGestureCollection();
            inputs.Add(new KeyGesture(Key.R, ModifierKeys.Control, "Ctrl+R"));
            requery = new RoutedUICommand(
              "Requery", "Requery", typeof(DataCommands), inputs);
        }

        public static RoutedUICommand Requery
        {
            get { return requery; }
        }
    }

(注意,是类的一个静态属性).


2,使用该命令:

posted @ 2020-05-21 08:53  frogkiller  阅读(312)  评论(0编辑  收藏  举报