• WPF 组合快捷键(Ctrl+C)


    页面程序:

    <Window x:Class="WpfDataGrid.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window1" Height="300" Width="300">
        <Window.Resources>
            <RoutedUICommand x:Key="btnClick" Text="Button Click"/> 
        </Window.Resources>
        <Window.InputBindings>
            <KeyBinding Gesture="Ctrl+C" Key="C" Command="{StaticResource btnClick}"/>
        </Window.InputBindings>
        <Window.CommandBindings>
            <CommandBinding Command="{StaticResource btnClick}"
                            CanExecute="CommandBinding_CanExecute"
                            Executed="CommandBinding_Executed"/>
        </Window.CommandBindings>
        <Grid>
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="105,76,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
        </Grid>
    </Window>

    后台代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    namespace WpfDataGrid
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, RoutedEventArgs e)
            {
                MainWindow main = new MainWindow();
                main.ShowDialog();
            }

            private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute = true;
            }

            private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
            {
                button1_Click(this, null);
            }
        }
    }

  • 相关阅读:
    python的类基础
    python导入模块
    python常用的内置函数
    python基础一数据类型之集合
    python函数-匿名函数
    python的函数(三)
    python的函数(二)
    python的函数(一)
    BZOJ4104:[Thu Summer Camp 2015]解密运算——题解
    BZOJ4033:[HAOI2015]树上染色——题解
  • 原文地址:https://www.cnblogs.com/RR-ghost/p/5437805.html
Copyright © 2020-2023  润新知