SetTargetWithoutContext() публичный статический Метод

Sets the target of the ActionMessage .
The DataContext will not be set.
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 .
Результат void
Пример #1
0
        /// <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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        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); }
            }
            ;
        }
Пример #4
0
        /// <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();
        }