Example #1
0
        public void RemoveBinding(ViewModelBase model, InputBinding binding)
        {
            FrameworkElement element = model.ViewElement as FrameworkElement;

            if (element == null)
            {
                return;
            }

            InputBindingCollection elementBindings = element.InputBindings;

            // need to find the exact class instance that was added.
            for (int i = elementBindings.Count - 1; i >= 0; i--)
            {
                if (!BindingsEqual(elementBindings[i], binding))
                {
                    continue;
                }
                Console.WriteLine("removing binding: " + binding.Gesture);
                this.GetBindingList(model).Remove(elementBindings[i]);
                elementBindings.RemoveAt(i);

                return;
            }             // for-loop.
        }
Example #2
0
 private static void CleanupInputBindings(InputBindingCollection inputBindings)
 {
     for (int i = inputBindings.Count - 1; i >= 0; i--)
     {
         if (inputBindings[i] is InputBindingEx)
         {
             inputBindings.RemoveAt(i);
         }
     }
 }