zoukankan      html  css  js  c++  java
  • 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);
            }
        }
    }

  • 相关阅读:
    九九乘法表及双色球
    错误 “SCRIPT7002: XMLHttpRequest: 网络错误 0x2ef3, ie浏览器兼容问题
    隐藏ie input的X和眼睛图标
    vue-cli解决兼容ie的es6+api问题
    git 本地tag和远程tag对应不上 vscode里pull不下代码
    git 计算commit
    git 查看对比的方法log diff
    git 版本回退方法
    git rebase的使用
    git 常规操作
  • 原文地址:https://www.cnblogs.com/RR-ghost/p/5437805.html
Copyright © 2011-2022 走看看