views:

75

answers:

2

Hi,

I am trying to workout how my silverlight application is going to work.

I want it to fill the browser.

I will have a like home page that will allow login.

Then it will open up a search page to list data

And then on selection goto the detail page of selected item.

But my question is how do I structure the app to goto these "pages" as I call them.

Do I have a user control for each logical page and then load that user control?

How is that done in the code loading user controls could you explain please? Does there have to be a base user control???

Malcolm

+1  A: 

The easiest way to go about it in Silverlight 2.0 is to put a ContentControl in your Page, along with navigation controls (a menu or some buttons to select pages if you have several root pages).

Each "Page" is created as a user control, and you display it by setting the Content property of the contentcontrol to an instance of your usercontrol.

So, for example: Page (inherits from UserControl, created by VS): contains a ContentControl, named MainContent

Login (inherits from UserControl) Search (inherits from UserControl) Details (inherits from UserControl) etc

When going from search to Details, for example, if Details takes the Id of the object to be displayed: MainContent.Content = New Details(SelectedItem.Id)

Let me know if you need more details, depneding on your proficiency with xaml and silverlight.

Side Note: Silverlight 3 comes with a built-in mechanism for that, but that's not gonna elp you right now.

EDIT: The Silverlight afficionados will have noted that there is no "Page" class in Silverlight 2.0, I was talking about the class named "Page" created by VS, which is a UserControl. I corrected my entry

Denis Troller
When you say a ContentControl in your page, you mean in the root usercontrol?? Because when you create a new silverlight project it gives you a a user control to start with?? Is there a page class?
Malcolm
Sorry, It's a UserControl, it's just named page by default I think. Between Silverlight 2, WPF and Silverlight 3 I get lost these days :)
Denis Troller
A: 

Take a look at this blog post

http://blogs.msdn.com/dphill/archive/2008/10/07/silverlight-navigation-part-1.aspx

bendewey