public static void SetHandlers(DependencyObject owner, CommandHandlerCollectionBinding commands) { owner.SetValue(HandlersProperty, commands); var collection = commands as INotifyCollectionChanged; if(collection != null) { collection.CollectionChanged += CommandHandlersCollectionChanged; } }
public static CommandHandlerCollectionBinding GetHandlers(DependencyObject owner) { if(owner == null) { throw new ArgumentNullException("owner"); } var collection = owner.GetValue(HandlersProperty) as CommandHandlerCollectionBinding; if(collection == null) { collection = new CommandHandlerCollectionBinding { Owner = owner }; SetHandlers(owner, collection); } return collection; }