Using NavigationService
To use navigation service to navigate between pages
string url = "/Page1.xaml";
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new System.Uri(url, UriKind.RelativeOrAbsolute));
Alternative approach
Using uri
string url = "/Page1.xaml";
NavigationWindow nav = this.Parent as NavigationWindow;
nav.Navigate(new System.Uri(url, UriKind.RelativeOrAbsolute));
Using object
NavigationWindow nav = this.Parent as NavigationWindow;
nav.Navigate(new Page1());
these both approach will achieve the navigation too. above sample will only work when you are using them from the child of NavigationWindow i.e. CheckLogin.xaml in this case. alternatively you may find the appropriate parent by some helper functions.
Eg.
NavigationWindow nav = FindAncestor<NavigationWindow>(this);
public static T FindAncestor<T>(DependencyObject dependencyObject) where T : DependencyObject
{
var parent = VisualTreeHelper.GetParent(dependencyObject);
if (parent == null) return null;
var parentT = parent as T;
return parentT ?? FindAncestor<T>(parent);
}
Using LinkNavigator
you may need to specify the frame target
string url = "/MainWindow.xaml";
BBCodeBlock bbBlock = new BBCodeBlock();
bbBlock.LinkNavigator.Navigate(new Uri(url, UriKind.Relative), this, NavigationHelper.FrameSelf);
following options can be specified for frame target
//Identifies the current frame.
public const string FrameSelf = "_self";
//Identifies the top frame.
public const string FrameTop = "_top";
//Identifies the parent of the current frame.
public const string FrameParent = "_parent";