0

I am developing a windows app which allows users to order Ice Creams. I am trying to make a button to navigate to another page called "logorder" but keep getting an error. I have uploaded a picture to show the error.Click here for the image

Code

Public NotInheritable Class MainPage
Inherits Page

Public Property NavigationService As Object


''' <summary>
''' Invoked when this page is about to be displayed in a Frame.
''' </summary>
''' <param name="e">Event data that describes how this page was reached.
''' This parameter is typically used to configure the page.</param>
Protected Overrides Sub OnNavigatedTo(e As Navigation.NavigationEventArgs)
    ' TODO: Prepare the page for display here.

    ' TODO: If your application contains multiple pages, ensure that you are
    ' handling the hardware Back button by registering for the
    ' Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
    ' If you are using the NavigationHelper provided by some templates,
    ' this event is handled for you.

End Sub

Private Sub HyperlinkButton_Click(sender As Object, e As RoutedEventArgs)

End Sub

Private Sub button_Copy_Click(sender As Object, e As RoutedEventArgs) Handles button_Copy.Click

    NavigationService.Navigate(New Uri("/logorder.xaml", UriKind.Relative))


End Sub
End Class

Xaml...

<Page
x:Class="mobileapps.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:mobileapps"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid>
    <Button x:Name="button_Copy" Content="Summary"     HorizontalAlignment="Left" Margin="96,425,0,0" VerticalAlignment="Top" Width="191"/>
    <HyperlinkButton Content="HyperlinkButton" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <HyperlinkButton Content="HyperlinkButton" HorizontalAlignment="Left" Margin="-232,186,0,0" VerticalAlignment="Top"/>
    <HyperlinkButton Content="HyperlinkButton" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <HyperlinkButton Content="HyperlinkButton" HorizontalAlignment="Left" VerticalAlignment="Top"/>
    <HyperlinkButton Content="Log order" HorizontalAlignment="Left" Margin="134,332,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.106,-0.496" Click="HyperlinkButton_Click" NavigateUri="logorder.xaml"/>
    <HyperlinkButton NavigateUri="logorder.xaml" />

</Grid>

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
salman12
  • 21
  • 1
  • 7

2 Answers2

0

You never set NavigationService, but try to call a method on it, so you will get a NullReferenceException

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
0

Try this

Private Sub HyperlinkButton_Click(sender As Object, e As RoutedEventArgs)
     Me.Frame.Navigate(GetType(BasicPage2))
End Sub 

How to perform navigation between pages in windows phone

Similar SO Question

Community
  • 1
  • 1
Eldho
  • 7,795
  • 5
  • 40
  • 77