|
在UserControl页面:
xaml中加入了一个Button,有一个click事件Button_Click
cs代码:
public event EventHandler goClick;
private void Button_Click(object sender, RoutedEventArgs e)
{
var h = goClick;
if (h != null)
{
h(this, e);
}
}
在调用UserControl的Page页中的xaml:
引入命名空间:
xmlns:my="clr-namespace:YourUserControlSolutionNameHere"
添加UserControl:
cs代码定义并处理点击事件:
userControl.goClick += new EventHandler(userControl_goClick);
void userControl_goClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/PivotPage1.xaml", UriKind.Relative));
}
OK,跳转结束。 |
|
|