navigating through pages and links ( code )

Nov 9, 2013 at 1:05 PM
I have the following code triggered by a button click :
MainWindow mainWindow = ((MainWindow)Application.Current.MainWindow);
mainWindow.MenuLinkGroups.Clear();
mainWindow.TitleLinks.Clear();

var linkTestGroup1 = new LinkGroup { DisplayName = "Home", GroupName = "Home" };
var link1 = new Link { DisplayName = "login", Source = new Uri("/Pages/Login.xaml", UriKind.Relative) };

linkTestGroup1.Links.Add(link1);
mainWindow.MenuLinkGroups.Add(linkTestGroup1);
Whats it does is it clears all groups and links in my main window and it adds a new Home group as well as a login link.The problem is that I want the login link to be selected ,because what happens now is that I get blank content and I have to click the login link to display its content.

To summarize I want to be able to navigate to a selected page or link ( for example group 2 link 3) or at least solve the problem above.
Nov 13, 2013 at 4:48 PM
Edited Nov 13, 2013 at 4:49 PM
You have to add the content source to your mainWindow.
mainWindow.ContentSource = new Uri("/Pages/Login.xaml", UriKind.Relative);
With this code your Page should be set to the login page.