Home > Net >  WPF road by the command don't pass up e.H andled=true;
WPF road by the command don't pass up e.H andled=true;

Time:11-13

Xaml:
XMLNS="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
XMLNS: x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Name="fdsafsd" Button. Click="_stackPanel_Click_2 & gt;"

<_btnClear Button x: Name="" Height=" 100 "Margin=" 5 "Button. Click=" _stackPanel_Click_fd & gt;"





Using System;
using System.Collections.Generic;
Using System. Linq;
Using System. The Text;
Using System. The Threading. The Tasks;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. The Data;
Using System. Windows. The Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;

The namespace WpfCommad
{
///& lt; Summary>
///MainWindow. Xaml interaction logic
///& lt;/summary>
Public partial class MainWindow: Window
{///& lt; Summary>
///declare and define command
///& lt;/summary>
Private RoutedCommand _clearCmd=new RoutedCommand (" clear ", typeof (MainWindow));
Private RoutedCommand _clearCmd1=new RoutedCommand (" clear1 ", typeof (MainWindow));
Public MainWindow ()
{
InitializeComponent ();
//specified command source and shortcut keys (input handwriting)
_btnClear. The Command=_clearCmd;
_btnClear1. The Command=_clearCmd1;
_clearCmd. InputGestures. Add (new KeyGesture (Key. C, ModifierKeys. Alt));

//specified command target
_btnClear. CommandTarget=_txtBox;
_btnClear1. CommandTarget=_txtBox;
//create a command associated
CommandBinding cb=new CommandBinding ();
Cb.Com mand=_clearCmd;
Cb. CanExecute +=cb_CanExecute;
Cb. +=cb_Executed Executed;

CommandBinding cb1=new CommandBinding ();
Cb1.Com mand=_clearCmd1;
Cb1. CanExecute +=cb_CanExecute;
Cb1. +=cb_Executed1 Executed;
//command associated to the peripheral control
_stackPanel. CommandBindings. Add (cb);
_stackPanel. CommandBindings. Add (cb1);
}
Void cb_Executed (object sender, ExecutedRoutedEventArgs e)
{
_txtBox. The Clear ();
MessageBox. Show (" event processing complete 1 ");

//has been completedE.H andled=true;
}

Void cb_Executed1 (object sender, ExecutedRoutedEventArgs e)
{
_txtBox. The Clear ();
MessageBox. Show (" event processing complete 2 ");

//has been completedE.H andled=true;
}

Void cb_CanExecute (object sender, CanExecuteRoutedEventArgs e)
{
If (string. IsNullOrEmpty (_txtBox. Text))
{
E.c. with our fabrication: anExecute=false;
}
The else
{
E.c. with our fabrication: anExecute=true;
}
E.H andled=true;
}

Private void _stackPanel_Click_1 (object sender, RoutedEventArgs e)
{
//MessageBox. Show (" event rose to a panel ");
}

Private void _stackPanel_Click_2 (object sender, RoutedEventArgs e)
{
//MessageBox. Show (" events up to the Window ");
}

Private void _stackPanel_Click_fd (object sender, RoutedEventArgs e)
{
MessageBox. Show (" increased event to the button ");
}

Private void _stackPanel_Click_fd1111 (object sender, RoutedEventArgs e)
{
Rose MessageBox. Show (" event for the ");
}
}
}
I on this page to add the two routing command a _clearCmd, a _clearCmd1, now want to achieve _clearCmd1 executed first, and then _clearCmd execution, judge said e.H andled=true can prevent routing transferred upwards, do not add this sentence in my code, why still don't want to pass on orders?
  •  Tags:  
  • C#
  • Related