Saturday, February 04, 2012
Blog
Oct 10

Written by: New Age Solution
10/10/2009 9:53 AM  RssIcon

When first time learning Silverlight even simple as going from Silverlight page to page seems to be strange. We will look at very simple solution to the problem of navigatin from page to page.

Lots of times we want to be able to navigate from Silverlight page to page in code behind or in ViewModel. Say we have button and on Click we want to programmatically navigate to this page.

 

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)

{

     NavigationService.Navigate(new Uri("/About", UriKind.RelativeOrAbsolute));

}

Notice that we are using NavigationService. But how do we know where to navigate?

In MainPage.xaml:

 

<navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}"

                Source="/Home" Navigated="ContentFrame_Navigated" NavigationFailed="ContentFrame_NavigationFailed">

    <navigation:Frame.UriMapper>

      <uriMapper:UriMapper>

        <uriMapper:UriMapping Uri="" MappedUri="/Views/Home.xaml"/>

        <uriMapper:UriMapping Uri="/{pageName}" MappedUri="/Views/{pageName}.xaml"/>

      </uriMapper:UriMapper>

    </navigation:Frame.UriMapper>

</navigation:Frame>

In NavigationService.Navigate, we can provide any of the Uri's specified in UriMapping.

That's it!


Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 


Tags


Blog Archive


Blog List


Search Blog


Google Reader


Blog Comments
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
Re: Silverlight 4 PathListBox
Nope you dont need blend.
Re: Silverlight 4 PathListBox
I have visual studio 2010, do you have to have expression blend to execute the above code? Thanks.
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
re:
I’m impressed. Very informative and trustworthy blog does exactly what it sets out to do. I’ll bookmark your weblog for future use.

Joseph
www.joeydavila.com
Your online Library
Re: How to fix TF215032 when trying to delete Build Definition from TFS?
Thanks you very much.
Re: DotNetNuke PermanentRedirect Error
Thanks so much for posting this! It fixed my issue.
Re: Why we are using our own custom blog using DotNetNuke?
Word Press is good too. see Blog.ToeTapz.com. Depends on what you need. I use DNN blog because it gives me ultimate control on what I want and what I need. Also I need to be able to upload Silverlight demo so I use DNN. BlogToeTapz.com I recently got is using word press and I been happy with it so far.
I am testing DNN blogs and they are not as good as blogger.com
Are there any other DNN blogs we can use for this?

http://newmediaworlds.blogspot.com/





Re: How to add Google Email, Calendar, and contacts to Blackberry and iPhone?
Great and detail instructions. I got just got my Blackberry 8350 and it's a very useful information for me as a newbie.


Syndicate  

Privacy Statement  |  Terms Of Use
Copyright 2010 New Age Solution