views:

95

answers:

2

In a Silverlight 3.0 app, there is a shell page that serves as the navigation piece for a number of child controls and other Silverlight pages. The Silverlight pages are included in the shell page via the Frame object (). The pages are rotated dynamically via the code-behind file, so there isn't a direct reference to them in the xaml.

How can these dynamically included pages call back to the shell page? We are currently using events to communicate from the included user controls, but these are known events that we can subscribe to in xaml...so if suggesting events, please include concrete examples.

TIA.

A: 

I would recommend using Prism developed by the Patterns and Practices Team.

Prism (through the EventAggregator) allows you to push notifications from any source out to listeners of the event you have specified. It's rather cool.

This is a video about communicating between views through Prism: http://channel9.msdn.com/posts/akMSFT/Creating-a-modular-application-using-Prism-v2-Screencast-44--Decoupled-Communication/

Jeremiah
A: 

If you are creating each child control from the parent page, you might be able to use delegates to accomplish this. Very generic example:

public delegate void FunctionDelegate(string ChildControlName);

In the parent container class:

    public FunctionDelegate EventFunc;

In the parent container constructor:

        EventFunc = DoSomeAction;

Pass EventFunc to the child object and call when appropriate.

JML