Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 Navigation frame, how to set its source
3 replies. Latest Post by AustinLamb on July 1, 2009.
(0)
karlsson...
Member
1 points
77 Posts
06-29-2009 3:19 AM |
Hi
I have one UserControl- 'MainPage'. MainPage contains a navigation:frame 'frm_Navigation' I don't have a source in my xaml code so the first time the Mainpage is displayd, the 'content area' is empty. I also have a treeview in mainpage which I use for navigation, this displays different pages in frm_Navigation. This works fine.
What I now need to accomplish is that the content in navigation:frame must display different pages from time to time when its first initialized (the user should not need to click in the treeview). I need a method in my mainpage.cs that checks certain criteria and then displays the correct page in navigation:frame.
I don't know how to accomplish this, I tried to simple run navigate
frm_Navigation.Navigate(uri); in MainPage straight after InitializeComponent, but it wont work.
Any suggestions?
paru
164 points
28 Posts
06-29-2009 5:44 AM |
Did you put the uri as absolute or relative?
this.Frame.Navigate(new Uri(goToPage, UriKind.Relative));
06-29-2009 6:17 AM |
I tried both
Relative is the one I use when the user clicks in the navigation menu. But in this scenario it throws a null exception.
I tried absolute as well, wont work.
AustinLamb
602 points
104 Posts
07-01-2009 7:34 PM |
There was a bug in the beta where calling Navigate() before Frame's Loaded event was raised would throw an exception - this has been fixed for release.
As a workaround, you should be able to set Frame.Source to the Uri of the Source page, even in InitializeComponent.