Exemplo n.º 1
0
        public static void UnregisterCommandsRecursive(FrameworkElement obj)
        {
            var pnl = obj as Panel;

            if (pnl != null)
            {
                foreach (var item in pnl.Children)
                {
                    UnregisterCommandsRecursive(item as FrameworkElement);
                }
            }
            CommandSubscription.UnregisterAllSubscriptions(obj);
        }
Exemplo n.º 2
0
        /// <summary>
        /// occurs when the command change on a <see cref="DependencyObject"/>
        /// </summary>
        /// <param name="d">The dependency object.</param>
        /// <param name="e">The <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void CommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is FrameworkElement)
            {
                var elem        = (FrameworkElement)d;
                var oldCommands = e.OldValue as string;
                if (!string.IsNullOrEmpty(oldCommands))
                {
                    foreach (var item in oldCommands.Split(' '))
                    {
                        CommandSubscription.UnregisterSubscription(item, elem);
                    }
                }

                var newCommands = e.NewValue as string;
                if (!string.IsNullOrEmpty(newCommands))
                {
                    foreach (var item in newCommands.Split(' '))
                    {
                        CommandSubscription.RegisterCommand(item, elem);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public static void UnregisterCommands(FrameworkElement obj)
 {
     CommandSubscription.UnregisterAllSubscriptions(obj);
 }