Esempio n. 1
0
        /// <summary>
        /// Retrieves the mapping collection
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static CommandEventCollection GetMappings(DependencyObject obj)
        {
            var map = obj.GetValue(MappingsProperty) as CommandEventCollection;

            if (map == null)
            {
                map = new CommandEventCollection();
                SetMappings(obj, map);
            }
            return(map);
        }
Esempio n. 2
0
        /// <summary>
        /// This changes the event mapping
        /// </summary>
        /// <param name="target"></param>
        /// <param name="e"></param>
        private static void OnMappingsChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
        {
            var sender = target as FrameworkElement;

            if (sender != null)
            {
                if (e.OldValue != null)
                {
                    CommandEventCollection cec = e.OldValue as CommandEventCollection;
                    if (cec != null)
                    {
                        cec.Unsubscribe(target);
                    }
                }
                if (e.NewValue != null)
                {
                    CommandEventCollection cec = e.NewValue as CommandEventCollection;
                    if (cec != null)
                    {
                        cec.Subscribe(target);
                    }
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// This sets the mapping collection.
 /// </summary>
 /// <param name="obj">Dependency Object</param>
 /// <param name="value">Mapping collection</param>
 public static void SetMappings(DependencyObject obj, CommandEventCollection value)
 {
     obj.SetValue(MappingsProperty, value);
 }