private void Initialize(object viewObject, bool isViewLoaded)
{
_view = new WeakReference(viewObject);
_isViewLoadState = true;
IsLoaded = isViewLoaded;
_isViewLoadState = viewObject is IViewLoadState;
if (this.SubscribeToWeakGenericEvent<LoadedEventArgs>(viewObject, "Loaded", OnViewLoadStateLoaded, false) == null)
{
Log.Debug("Failed to use weak events to subscribe to 'view.Loaded', going to subscribe without weak events");
((IView) viewObject).Loaded += OnViewLoadStateLoaded;
}
if (this.SubscribeToWeakGenericEvent<LoadedEventArgs>(viewObject, "Unloaded", OnViewLoadStateUnloaded, false) == null)
{
Log.Debug("Failed to use weak events to subscribe to 'view.Unloaded', going to subscribe without weak events");
((IView)viewObject).Unloaded += OnViewLoadStateUnloaded;
}
#if SILVERLIGHT
var view = View;
this.SubscribeToWeakGenericEvent<LayoutUpdatedEventArgs>(view, "LayoutUpdated", OnLayoutUpdated);
#endif
}