Microsoft Silverlight 2.0 Beta 2 – How to navigate between xaml pages

Add the following to the app.xaml.vb:

 Dim mainUI As Grid = New Grid()

In Private Sub Application_Startup

 Me.RootVisual = mainUI

Add sub:

 Public Sub GoToPage(ByVal nextPg As UserControl)
      Dim app As App = CType(Application.Current, App)
      ' Remove the displayed page
      app.mainUI.Children.Clear()
      ' Show the next page
      app.mainUI.Children.Add(nextPg)
 End Sub

Then in your page:

 Private Sub btnLogon_Click1(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnLogon.Click
      Try
           Dim app As App = CType(Application.Current, App)
           app.GoToPage(New PendListPage())
      Catch ex As Exception
           clsExceptionRoutine.Exception_Routine(ex)
      End Try
 End Sub

Leave a Reply