Example #1
0
        public static void SetInputBinding(InputBindingCollection inputCollection, ICommand command, InputGesture gesture)
        {
            var binding = new InputBinding(command, gesture);

            inputCollection.Remove(binding);
            inputCollection.Add(binding);
        }
Example #2
0
 private static void DeregisterCommands()
 {
     foreach (var keyBinding in _stash)
     {
         _inputBindings.Remove(keyBinding);
     }
 }
Example #3
0
 /// <inheritdoc />
 protected override void Unbind(ShortcutBinding binding)
 {
     if (!mapping.TryGetValue(binding, out var input))
     {
         return;
     }
     mapping.Remove(binding);
     inputBindings.Remove(input);
 }
Example #4
0
 /// <summary>
 /// Remove if modifiers and key matched
 /// </summary>
 public static void MatchedRemove(this InputBindingCollection coll, KeyBinding kb)
 {
     foreach (KeyBinding elem in coll)
     {
         if (elem.Modifiers == kb.Modifiers && elem.Key == kb.Key)
         {
             coll.Remove(elem);
             return;
         }
     }
 }
Example #5
0
        public void DeregisterCommands()
        {
            if (_inputBindings == null)
            {
                return;
            }

            foreach (var keyBinding in _stash)
            {
                _inputBindings.Remove(keyBinding);
            }
        }
Example #6
0
        /// <summary>
        /// Clear any bindings currently tied to a view model.
        /// </summary>
        /// <param name="model"></param>
        public void RemoveBindings(ViewModelBase model)
        {
            FrameworkElement element = model.ViewElement as FrameworkElement;

            if (element == null)
            {
                return;
            }

            InputBindingCollection elementBindings = element.InputBindings;
            List <InputBinding>    bindings;

            if (bindingGroups.TryGetValue(model, out bindings))
            {
                foreach (InputBinding b in bindings)
                {
                    elementBindings.Remove(b);
                }
                Console.WriteLine("BINDING REMOVE COUNT: " + bindings.Count);
                bindings.Clear();
            }
        } //