SL 3 navigation not working!
- by Silver Gun
Hey Guys
I converted all my existing Silverlight app UserControls to Pages so I could use the Navigation Framework.
Anyway so I created a UserControl called MyFrame, which would host all the pages.
In my App.xaml.cs I have the following to make sure that MyFrame is loaded when the App loads:
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MyFrame();
}
My UriMapper class resides in App.xaml and looks like the following:
<navcore:UriMapper x:Key="uriMapper">
<navcore:UriMapping Uri="Login" MappedUri="Login.xaml">
</navcore:UriMapper>
Within my 'MyFrame' class, I have the following
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<HyperlinkButton Tag="Login" Content="Login" Click="HyperlinkButton_Click" />
</StackPanel>
<StackPanel Orientation="Vertical">
<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" />
</StackPanel>
</StackPanel>
And within the callback for my HyperlinkButton's event handler, I have the following:
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
ContentFrame.Navigate(new Uri((sender as HyperlinkButton).Tag.ToString(), UriKind.Relative));
}
The Login.xaml file is in my root folder (right under Project). This navigation does not seem to work!
The exception I get reads like so:
Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.
Parameter name: uri
The Login page does not load. There is no problem with Login.xaml as when I set
this.RootVisual = new Login();
the page loads just fine.
I also tried setting the NavigateUri attribute of the HyperlinkButton to "Login." No cigar.
I'll appreciate any help!
Thanks a lot in advance