Windows Phone 8.1中如何使用HyperlinkButton显示ContentDialog页面
How to use HyperlinkButton to show ContentDialog page in Windows Phone 8.1
如何使用 HyperlinkButton
在 Windows 中显示 ContentDialog
页面 Phone 8.1.
XAML:
<HyperlinkButton NavigateUri="Login/ForgotPassword.xaml">
<TextBlock>
<Underline>
<Run>Forgot Password?</Run>
</Underline>
</TextBlock>
</HyperlinkButton>
ForgotPassword.xaml
是 ContentDialog
页面,存在于 View
文件夹中。
通过使用此 XAML 代码,我在单击事件时关注 windows 屏幕:
这不是预期的。我在这里遗漏了什么吗?
HyperlinkButton.NavigateUri 被 WebView 使用:
The action of opening the NavigateUri in a default browser is a system action that takes place without requiring any event handling. If your intent is that the HyperlinkButton should load a specified URI within a WebView control that's also part of your app, then don't specify a value for NavigateUri. Handle the Click event instead, and call WebView.Navigate, specifying the URI to load.
如果您想导航到应用程序中的页面或显示对话框,请使用 Click event:
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
// navigation to Page:
this.Frame.Navigate(typeof(ForgotPassword));
// if you need to show a dialog (it must be defined somewhere in your page clas), then make the whole event async
ForgotPassword dialog = new ForgotPassword();
await dialog.ShowAsync();
}
在XAML中:
<HyperlinkButton Click="HyperlinkButton_Click">
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
ContentDialog testDialog = new ContentDialog()
{
Title = "Testing",
Content = "We are still testing this contentDialog",
PrimaryButtonText = "Ok"
};
await testDialog.ShowAsync();
}
如何使用 HyperlinkButton
在 Windows 中显示 ContentDialog
页面 Phone 8.1.
XAML:
<HyperlinkButton NavigateUri="Login/ForgotPassword.xaml">
<TextBlock>
<Underline>
<Run>Forgot Password?</Run>
</Underline>
</TextBlock>
</HyperlinkButton>
ForgotPassword.xaml
是 ContentDialog
页面,存在于 View
文件夹中。
通过使用此 XAML 代码,我在单击事件时关注 windows 屏幕:
这不是预期的。我在这里遗漏了什么吗?
HyperlinkButton.NavigateUri 被 WebView 使用:
The action of opening the NavigateUri in a default browser is a system action that takes place without requiring any event handling. If your intent is that the HyperlinkButton should load a specified URI within a WebView control that's also part of your app, then don't specify a value for NavigateUri. Handle the Click event instead, and call WebView.Navigate, specifying the URI to load.
如果您想导航到应用程序中的页面或显示对话框,请使用 Click event:
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
// navigation to Page:
this.Frame.Navigate(typeof(ForgotPassword));
// if you need to show a dialog (it must be defined somewhere in your page clas), then make the whole event async
ForgotPassword dialog = new ForgotPassword();
await dialog.ShowAsync();
}
在XAML中:
<HyperlinkButton Click="HyperlinkButton_Click">
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
ContentDialog testDialog = new ContentDialog()
{
Title = "Testing",
Content = "We are still testing this contentDialog",
PrimaryButtonText = "Ok"
};
await testDialog.ShowAsync();
}