A piece of WPF code handles all click events, while the wpf code handles events.
You can use one method to control the forwarding of all click events, as shown in the following figure:
<Page x: 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> <Style TargetType = "Button"> <Setter Property = "Opacity" Value = "1"/> <Setter Property = "Width" Value = "40"/> <Setter property = "Height" Value = "40"/> </Style> </Page. resources> <! -- Set the Background image --> <Page. Background> <ImageBrush ImageSource = "Resources \ Phone \ Home3.png" Stretch = "Fill"/> <! -- Stretch --> </Page. background> <StackPanel Name = "MyHome" ButtonBase. click = "MyHome_Click"> <Canvas Height = "400" Width = "240"> <! -- Clock --> <Button Opacity = "0" x: Name = "Colck" Canvas. Left = "10" Canvas. Top = "20"/> <! -- Calendar --> <Button Opacity = "0" x: Name = "RiLi" Canvas. Left = "70" Canvas. Top = "22"/> <! -- Music --> <Button Opacity = "0" x: Name = "Muesic" Canvas. Left = "130" Canvas. Top = "22"/> <! -- Network --> <Button Opacity = "0" x: Name = "Web" Canvas. Left = "190" Canvas. Top = "22"/> <! -- Camera --> <Button Opacity = "0" x: Name = "Camary" Canvas. Left = "10" Canvas. Top = "90"/> <! -- Email --> <Button Opacity = "0" x: Name = "Email" Canvas. Left = "70" Canvas. Top = "90"/> <! -- Album --> <Button Opacity = "0" x: Name = "photos" Canvas. Left = "130" Canvas. Top = "90"/> <! -- Search --> <Button Opacity = "0" x: Name = "Seching" Canvas. Left = "190" Canvas. Top = "90"/> <! -- Video --> <Button Opacity = "0" x: Name = "Viodue" Canvas. left = "10" Canvas. top = "165" Click = "Viodue_Click"/> <! -- Radio --> <Button Opacity = "0" x: Name = "FM" Canvas. Left = "70" Canvas. Top = "165"/> <! ----> <Button Opacity = "0" x: Name = "AsmsungApp" Canvas. Left = "130" Canvas. Top = "165"/> <! -- Settings --> <Button Opacity = "0" x: Name = "Stetting" Canvas. Left = "190" Canvas. Top = "165"/> <! -- Social networking --> <Button Opacity = "0" x: Name = "Cluble" Canvas. Left = "10" Canvas. Top = "235"/> <! -- WebViolue --> <Button Opacity = "0" x: Name = "WebViolu" Canvas. Left = "70" Canvas. Top = "235"/> <! ----> <Button Opacity = "0" x: Name = "Read" Canvas. left = "130" Canvas. top = "235"/> <Button Opacity = "0" x: Name = "backNode" Canvas. left = "190" Canvas. top = "235"/> <Button Opacity = "0" x: Name = "Call" Canvas. left = "10" Canvas. top = "350"/> <! -- WebViolue --> <Button Opacity = "0" x: Name = "TongXunlu" Canvas. Left = "70" Canvas. Top = "350"/> <! ----> <Button Opacity = "0" x: Name = "Messing" Canvas. left = "130" Canvas. top = "350"/> <Button Opacity = "0" x: Name = "Home" Canvas. left = "190" Canvas. top = "350" type = "codeph" text = "codeph"/> </Canvas> </StackPanel> </Page>
Resource file:
Process Code Logic
/// <Summary> /// Click Event /// </summary> /// <param name = "sender"> </param> /// <param name = "e"> </param> private void MyHome_Click (object sender, routedEventArgs e) {Button btn = (Button) e. originalSource; // obtain the clicked Button Type = this. getType (); // obtain its type Assembly assenbly = type. assembly; // Assembly information Page page = (Page) assenbly. createInstance (type. namespace + ". "+ btn. name); // create an instance NavigationService. navigate (new Uri (btn. name + ". xaml ", UriKind. relative); // start navigation}