WPF piece of code to fix all click events

Source: Internet
Author: User

A way to control the forwarding of all click events, the interface diagram is as follows:

<Pagex:class= "Wpfnavigate.index"xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"Title= "Home">    <page.resources>        <StyleTargetType= "button">            <Setter Property= "Opacity"Value= "1"/>            <Setter Property= "Width"Value= "Max"/>            <Setter Property= "Height"Value= "Max"/>        </Style>    </page.resources>    <!--set a background picture -    <Page.background>        <ImageBrushImageSource= "Resources\phone\home3.png"Stretch= "Fill" />        <!--Stretch Stretching -    </Page.background>    <StackPanelName= "MyHome"Buttonbase.click= "Myhome_click">        <CanvasHeight= "The "Width= "+">            <!--Clock -            <ButtonOpacity= "0"x:name= "Colck"Canvas.Left= "Ten"Canvas.Top= " the" />            <!--Calendar -            <ButtonOpacity= "0"x:name= "Rili"Canvas.Left= "The "Canvas.Top= "All" />            <!--Music -            <ButtonOpacity= "0"x:name= "Muesic"Canvas.Left= "The "Canvas.Top= "All" />            <!--Network -            <ButtonOpacity= "0"x:name= "Web"Canvas.Left= " the"Canvas.Top= "All" />            <!--Camera -            <ButtonOpacity= "0"x:name= "Camary"Canvas.Left= "Ten"Canvas.Top= "All" />            <!--Mail -            <ButtonOpacity= "0"x:name= "Email"Canvas.Left= "The "Canvas.Top= "All" />            <!--albums -            <ButtonOpacity= "0"x:name= "Photos"Canvas.Left= "The "Canvas.Top= "All" />            <!--Search -            <ButtonOpacity= "0"x:name= "Seching"Canvas.Left= " the"Canvas.Top= "All" />            <!--Video -            <ButtonOpacity= "0"x:name= "Viodue"Canvas.Left= "Ten"Canvas.Top= "165"Click= "Viodue_click" />            <!--Radio -            <ButtonOpacity= "0"x:name= "FM"Canvas.Left= "The "Canvas.Top= "165" />            <!---->        <ButtonOpacity= "0"x:name= "Asmsungapp"Canvas.Left= "The "Canvas.Top= "165" />        <!--Set -            <ButtonOpacity= "0"x:name= "Stetting"Canvas.Left= " the"Canvas.Top= "165" />            <!--Social -            <ButtonOpacity= "0"x:name= "Cluble"Canvas.Left= "Ten"Canvas.Top= "235" />            <!--Webviolue -            <ButtonOpacity= "0"x:name= "Webviolu"Canvas.Left= "The "Canvas.Top= "235" />            <!---->        <ButtonOpacity= "0"x:name= "Read"Canvas.Left= "The "Canvas.Top= "235" />        <ButtonOpacity= "0"x:name= "Backnode"Canvas.Left= " the"Canvas.Top= "235" />         <ButtonOpacity= "0"x:name= "Call"Canvas.Left= "Ten"Canvas.Top= " the" />        <!--Webviolue -            <ButtonOpacity= "0"x:name= "Tongxunlu"Canvas.Left= "The "Canvas.Top= " the" />            <!---->        <ButtonOpacity= "0"x:name= "messing"Canvas.Left= "The "Canvas.Top= " the" />             <ButtonOpacity= "0"x:name= "Home"Canvas.Left= " the"Canvas.Top= " the" />    </Canvas>    </StackPanel></Page>

Resource file:

Handling code Logic

/// <summary>        ///Click events/// </summary>        /// <param name= "Sender" ></param>        /// <param name= "E" ></param>        Private voidMyhome_click (Objectsender, RoutedEventArgs e) {Button btn= (Button) E.originalsource;//get the button clickedType type = This. GetType ();//to get his typeAssembly assenbly = type. Assembly;//Assembly InformationPage page = (page) assenbly. CreateInstance (type. Namespace +"."+ BTN. Name);//Create an instanceNavigationservice.navigate (NewUri (btn. Name +". xaml", urikind.relative));//Start Navigation}

WPF piece of code to fix all click events

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.