Redirect to Another Page Within Silverlight

13. October 2009 06:55

Well this will be short, but I'm putting this out there because I just spent about an hour trying to figure out (probably wasn't searching correctly, and I'm a bit tired) how to do the equivalent of Response.Redirect in a Silverlight 3 navigation application.  Keep in mind this is my first ever navigation app with Silverlight 3.  I basically had a login page (Home.xaml) and if the login was successful I wanted to navigate to another page (Products.xaml) within the application dynamically.  So after searching google and bing...nothing was showing up how I wanted.  The results either had to do with moving to the next or previous history within the navigation, or some had to do with just swapping the content on the current page with the new page.

So it came down to this simple code to accomplish the same thing as a Response.Redirect in Silverlight:

if (isAuth)

   //some code here
  
this.NavigationService.Navigate(new Uri("/Products", UriKind.Relative));
}

else
{
 
MessageBox.Show("Incorrect Username or Password");
}

Tags:

Silverlight

blog comments powered by Disqus



My Random Thought

I think the OCW is a great thing to have available to those who are in school, just finished school or just want to educate themself

http://ocwconsortium.org/

John On Twitter

Discounts