示例#1
0
        /// <summary>
        /// Called after the action is attached to an AssociatedObject.
        /// </summary>
#if WINDOWS_UWP
        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();
        }
示例#2
0
        /// <summary>
        ///  Called after the action is attached to an AssociatedObject.
        /// </summary>
        protected override void OnAttached()
        {
            if (!View.InDesignMode)
            {
                Parameters.Attach(AssociatedObject);
                Parameters.OfType <Parameter>().Apply(x => x.MakeAwareOf(this));

                // This is a real hack, we don't have access to a Loaded event so
                // working out when the "visual tree" is active doesn't really happen
                // We don't have many events to choose from. Thankfully

                EventHandler bindingContextChanged = null;

                bindingContextChanged = (s, e) => {
                    AssociatedObject.BindingContextChanged -= bindingContextChanged;
                    ElementLoaded();
                };

                AssociatedObject.BindingContextChanged += bindingContextChanged;
            }

            base.OnAttached();
        }