1

I would like to use the NavigationService to create a nice navigation stack in a Windows Phone 7 app. It seems I can accomplish the objective in SilverLight by using the NavigationService.Navigate(object) method and passing an object similar to the PhoneApplicationPage.

Based on the searching I've done, Windows Phone 7 only allows use of the NavigationService when the desired output is provided in XAML. I would like to pass the NavigationService an object I created using C# syntax and not XAML.

Does anyone have a suggestion?

tshepang
  • 12,111
  • 21
  • 91
  • 136
benhorgen
  • 1,928
  • 1
  • 33
  • 38

1 Answers1

2

When developing for Windows Phone, there is only one signature for NavigationService.Navigate and that is NavigationService.Navigate(Uri). You're probably reading the documentation for WPF.

keyboardP
  • 68,824
  • 13
  • 156
  • 205
  • Correct, Windows Phone 7 API clearly defines that API as taking a URI only. Presumably the URI is for a XAML UI layout. I would like to build my UI using C#, not XAML. Is that possible? What if my UI is dynamic? Do I then need to create XAML for all possible UI variation for each screen... that doesn't seem possible for my particular problem. – benhorgen Aug 03 '11 at 20:22
  • XAML is a markup language and pretty much anything you can do in XAML, you can do in the code-behind. An example of adding controls can be seen here: http://www.c-sharpcorner.com/UploadFile/kirtan007/3110/ . Depending on what you're doing, you can add/remove UI controls from the XAML page using the method in the link. Also, since your UI is in C#, you could take another approach. Have a "host" `XAML` page that contains only a `Border` layout type. Then, depending on the object you want to load, simply set the `Border's` content to be that of your C# UserControl object. – keyboardP Aug 03 '11 at 20:55