简体   繁体   中英

Windows Phone page navigation does not work

I'm new in creating apps for Windows Phone. I've got problem with redirecting to another page. I've created blank page with HyperlinkButton and in .cs file I wrote this:

private void but_elf_Click(object sender, RoutedEventArgs e)
{
    this.Frame.Navigate(typeof(Elfy));
}

In xaml:

<HyperlinkButton x:Name="but_elf" Content="Elfy"  
    HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1" 
    VerticalAlignment="Center" Width="200" Height="70" />

When I launch app and click on the button - nothing happens. There are no errors, no messages. I've tried to put NavigateUri in button's property but after pressing button (in launched app) the message has shown: "You need to install an app for this task. Would you like to search for one in the Store?" After pressing "Yes" the app says: "Sorry, no apps found".

How to figure out this problem? I'm creating app for Windows Phone 8.1 in .NET Framework 4.5. Thanks for any help.

You are missing a reference for the 'Click'-event handler. Please change your XAML to this:

<HyperlinkButton x:Name="but_elf" Content="Elfy"  
HorizontalAlignment="Center" Margin="100,125,100,255" Grid.Row="1" 
VerticalAlignment="Center" Width="200" Height="70" Click="but_elf_Click" />

Please see:

C# Documentation for Click on MSDN

C# Documentation for HyperlinkButton on MSDN

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM