Tunneling Routed Events

Source: Internet
Author: User

Since learning WPF, it has been assumed that tunnel routed events were passed by the triggering control to its child controls, and heaven knew that the tunnel routed event was passed from the window to the current element!

Shame on me!

Paste a sample code to illustrate:

<Grid>        <BorderHeight= " the"Width= "+"BorderBrush= "Gray"borderthickness= "1" >            <StackPanelBackground= "Lightgray"Orientation= "Horizontal"Previewmouseleftbuttonup= "Stackpanel_previewmouseleftbuttonup"MouseUp= "Stackpanel_mouseup">                <TextBlockName= "Yestb"Width= " the"Previewmouseleftbuttonup= "Yestb_previewmouseleftbuttonup"MouseUp= "Yestb_mouseup"Background= "Blue" >Yes</TextBlock>            </StackPanel>        </Border>    </Grid>

Background code:

 Private voidYestb_mouseup (Objectsender, MouseButtonEventArgs e) {            //MessageBox.Show ("button");e.handled =true; }        Private voidStackpanel_mouseup (Objectsender, MouseButtonEventArgs e) {            //MessageBox.Show ("Panel");        }        Private voidYestb_previewmouseleftbuttonup (Objectsender, MouseButtonEventArgs e) {MessageBox.Show ("Buttonpreview"); }        Private voidStackpanel_previewmouseleftbuttonup (Objectsender, MouseButtonEventArgs e) {MessageBox.Show ("Panelpreview"); }

Program Run effect

When you click on the blue area, the "panelpreivew" dialog box pops up before the "Buttonpreview" dialog box pops up.

Study it!

Tunneling Routed Events

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.