Reputation: 3834
How to use HyperlinkButton
to show ContentDialog
page in Windows Phone 8.1.
XAML:
<HyperlinkButton NavigateUri="Login/ForgotPassword.xaml">
<TextBlock>
<Underline>
<Run>Forgot Password?</Run>
</Underline>
</TextBlock>
</HyperlinkButton>
ForgotPassword.xaml
is a ContentDialog
Page which is present in View
folder.
By using this XAML code I am getting following windows screen on click event:
Which is not expected. Anything I am missing here?
Upvotes: 1
Views: 1482
Reputation: 29792
HyperlinkButton.NavigateUri is used by 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.
If you want to navigate to a page in your app or show dialog, use 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();
}
In XAML:
<HyperlinkButton Click="HyperlinkButton_Click">
Upvotes: 2
Reputation: 16142
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();
}
Upvotes: 1