/// <summary>
        /// Called when the behavior is being detached from its AssociatedObject, but before it has actually occurred.
        /// </summary>
        /// <remarks>
        /// Override this to unhook functionality from the AssociatedObject.
        /// </remarks>
        protected override void OnDetaching()
        {
            base.OnDetaching();

            var mappings = EventCommander.GetMappings(AssociatedObject);

            if (mappings != null && _commandEvent != null)
            {
                mappings.Remove(_commandEvent);
            }
        }
        /// <summary>
        /// Hooks the event maps
        /// </summary>
        private void HookEvents()
        {
            var mappings = EventCommander.GetMappings(AssociatedObject);

            if (mappings == null)
            {
                mappings = new CommandEventCollection();
                EventCommander.SetMappings(AssociatedObject, mappings);
            }

            _commandEvent = new CommandEvent {
                Command = this, CommandParameter = this.CommandParameter, Event = this.Event
            };
            mappings.Add(_commandEvent);
        }