static void SetupCaliburnMicro <T>(T viewModel, IViewFor resolvedView) { var dependencyObject = (DependencyObject)resolvedView; dependencyObject.SetValue(View.IsGeneratedProperty, true); ViewModelBinder.Bind(viewModel, dependencyObject, null); Action.SetTargetWithoutContext(dependencyObject, viewModel); }
static void ItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var pager = (Pager)d; var source = (IBindablePagedQuery)e.NewValue; source.IsLoadingChanged += (s, args) => { var state = args.Value ? "Loading" : "Loaded"; Execute.OnUIThread(() => VisualStateManager.GoToState(pager, state, true)); }; Action.SetTarget(pager.LayoutRoot, e.NewValue); }
protected override void OnDeactivate(bool close) { var view = _cachedView as CharacteristicView; if (view == null) { return; } // fix for Caliburn's issue when conventions are not applied when cached view is activated. ToDo: report or fix Action.SetTarget(view, null); Action.SetTarget(view, this); }
static void SetupCaliburn(object rootModel, Popup popup, UIElement view) { ViewModelBinder.Bind(rootModel, popup, null); Action.SetTargetWithoutContext(view, rootModel); var activatable = rootModel as IActivate; activatable?.Activate(); var deactivator = rootModel as IDeactivate; if (deactivator != null) { popup.Closed += delegate { deactivator.Deactivate(true); } } ; }