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

            if (map == null)
            {
                map = new CommandEventCollection();
                SetMappings(obj, map);
            }
            return(map);
        }
Exemplo 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)
 {
     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);
         }
     }
 }
Exemplo 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);
 }