Passign object from one silverlight page to another

Passign object from one silverlight page to another

Old forum URL: forums.lhotka.net/forums/t/7666.aspx


zeevb posted on Tuesday, September 22, 2009

I am new to silverlight and to csla. Couldn't find a way to pass objects from one silverlight page to another but I came up with a way that seems to work and was wondering if this is the right way :

in the From page I handle the OnNavigatedFrom page and set the DataContext of the To page to whatever object I need to like the code below :

protected override void OnNavigatedFrom(NavigationEventArgs e)

{

base.OnNavigatedFrom(e);

PhotoViewer photoViewer = (PhotoViewer)e.Content;

photoViewer.DataContext = WorkOrderObj.PhotographList;

}

The To page NavigatedTo event occurs (at least in my machine) after the OnNavigatedFrom event in the From page. Does this way of passing objects from one page to another is the right/best way ?

 

RockfordLhotka replied on Tuesday, September 22, 2009

Navigation is an interesting problem.

The navigation frameworks (built into SL3, or from CSLA .NET) are designed around the assumption that a user might take a short-cut to the page in the browser, and might navigate directly to that page at some future time.

In other words, the frameworks are generally designed to assume the current page is the first page the user hits.

That's not what you are describing - you are describing a scenario where the user can't navigate directly to your page without hitting some other page first.

So I think your model is fine, as long as you handle the direct-navigation case and (presumably) re-route the user to some valid start point when they try to come in at an invalid start point.

zeevb replied on Tuesday, September 22, 2009

Thanks Rocky,

In the business context of how this application will be used, direct navigation to the"To" page does not make sense, it is a "child" page of the "From" page, so, I am leaning towards using this approach and gracefully handle the direct-navigation if it occurs for some reason.

 

Thanks

Zeev

Copyright (c) Marimer LLC