On the usercontrol page:
A button is added to XAML with a click event button_click.
<Grid X: Name ="Layoutroot">
<Button click ="Button_click"Style ="{Staticresource buttonstyle1}">
<Button. Background>
<Imagebrush imagesource ="Applicationicon.png"> </Imagebrush>
</Button. Background>
</Button>
</GRID>
CSCode:
Public EventEventhandler <routedeventargs> goclick;
Private VoidButton_click (ObjectSender, routedeventargs E)
{
VaRH = goclick;
If(H! =Null)
{
H (This, E );
}
}
On the page that calls usercontrol, The XAML:
Introduce namespace:
Xmlns: My ="CLR-namespace: yourusercontrolsolutionnamehere"
Add usercontrol:
<My: yourusercontrolclassname name ="Usercontrol"Width ="100"Height ="100"> </My: yourusercontrolclassname>
The CS Code defines and processes click events:
Usercontrol. goclick + =NewEventhandler <routedeventargs> (usercontrol_goclick );
VoidUsercontrol_goclick (ObjectSender, routedeventargs E)
{
Navigationservice. navigate (NewUri ("/Pivotpage1.xaml", Urikind. Relative ));
}
OK. The jump ends.