public static SetTargetWithoutContext ( global::Xamarin.Forms.BindableObject d, object target ) : void | ||
d | global::Xamarin.Forms.BindableObject | The element to attach the target to. |
target | object | The target for instances of |
return | void |
/// <summary> /// Shows a popup at the current mouse position. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="context">The view context.</param> /// <param name="settings">The optional popup settings.</param> public virtual void ShowPopup(object rootModel, object context = null, IDictionary <string, object> settings = null) { var popup = CreatePopup(rootModel, settings); var view = ViewLocator.LocateForModel(rootModel, popup, context); popup.Child = view; popup.SetValue(View.IsGeneratedProperty, true); ViewModelBinder.Bind(rootModel, popup, null); Action.SetTargetWithoutContext(view, rootModel); var activatable = rootModel as IActivate; if (activatable != null) { activatable.Activate(); } var deactivator = rootModel as IDeactivate; if (deactivator != null) { popup.Closed += delegate { deactivator.Deactivate(true); } } ; popup.IsOpen = true; popup.CaptureMouse(); }
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 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); } } ; }
/// <summary> /// Shows a popup at the current mouse position. /// </summary> /// <param name="rootModel">The root model.</param> /// <param name="context">The view context.</param> /// <param name="settings">The optional popup settings.</param> public virtual async Task ShowPopupAsync(object rootModel, object context = null, IDictionary <string, object> settings = null) { var popup = CreatePopup(rootModel, settings); var view = ViewLocator.LocateForModel(rootModel, popup, context); popup.Child = view; popup.SetValue(View.IsGeneratedProperty, true); ViewModelBinder.Bind(rootModel, popup, null); Action.SetTargetWithoutContext(view, rootModel); if (rootModel is IActivate activator) { await activator.ActivateAsync(); } if (rootModel is IDeactivate deactivator) { popup.Closed += async(s, e) => await deactivator.DeactivateAsync(true); } popup.IsOpen = true; popup.CaptureMouse(); }