Caliburn.Micro.View.ExecuteOnUnload C# (CSharp) Метод

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

Executes the handler when the element is unloaded.
public static ExecuteOnUnload ( global::Xamarin.Forms.VisualElement element, RoutedEventHandler handler ) : void
element global::Xamarin.Forms.VisualElement The element.
handler RoutedEventHandler The handler.
Результат void
        public static void ExecuteOnUnload(FrameworkElement element, RoutedEventHandler handler) {
#if !XFORMS
            RoutedEventHandler unloaded = null;
            unloaded = (s, e) => {
                element.Unloaded -= unloaded;
                handler(s, e);
            };
            element.Unloaded += unloaded;
#endif
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Called after the action is attached to an AssociatedObject.
        /// </summary>
#if WinRT81
        protected override void OnAttached()
        {
            if (!View.InDesignMode)
            {
                Parameters.Attach(AssociatedObject);
                Parameters.OfType <Parameter>().Apply(x => x.MakeAwareOf(this));


                if (View.ExecuteOnLoad(AssociatedObject, ElementLoaded))
                {
                    // Not yet sure if this will be needed
                    //var trigger = Interaction.GetTriggers(AssociatedObject)
                    //    .FirstOrDefault(t => t.Actions.Contains(this)) as EventTrigger;
                    //if (trigger != null && trigger.EventName == "Loaded")
                    //    Invoke(new RoutedEventArgs());
                }

                View.ExecuteOnUnload(AssociatedObject, ElementUnloaded);
            }

            base.OnAttached();
        }