Jan 7, 2011 at 6:15 PM
Edited Jan 7, 2011 at 6:19 PM
I posted this over on
Silverlight forums but am posting here as well because I figure people get notified of new Discussions :)
Basically, my ViewModels need to be aware of the View's Loaded event,
and its sender/EventArgs.
It appears that what I'm trying to do is impossible: RoutedEventArgs.OriginalSource is null even when wiring up a code-behind EventHandler, and I see no way to get the sender, unless I wire it manually.
It may be that I should be going about this a different way -- I'm just not sure what I should be doing instead.
My application is a windowed environment. I'm using a modeless ChildWindow control and a special WindowHost into which all windows are added (and also provides a taskbar).
When a user performs an action that should open a window, the ViewModel Command handling that action uses a helper class through which all window creations are funneled.
The problem with this is that the helper class needs to know about the WindowHost control on the MainPage, so it can add the ChildWindow to it.
How can I solve this problem without hard references between view & viewmodel, and without one-off code in the codebehind?