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);
            }
        }
    }

  • 相关阅读:
    【排序】SelectSort
    Linux下程序的Profile工具
    Ubuntu adb devices :???????????? no permissions 解决方法
    利用宏控制打印
    关于错误 Resource temporarily unavailable
    如何不使用pthread_cancel而杀死线程
    【排序】BubbleSort
    使用 autotools 生成包含多文件的 Makefile
    source命令使用
    2010 成都预选赛 Binary Number
  • 原文地址:https://www.cnblogs.com/RR-ghost/p/5437805.html
Copyright © 2011-2022 走看看