Files
Dustin Campbell d4122f3a0c Correct namespaces to be pascal-cased
Conflicts:
	xunit.runner.wpf/ViewModel/MainViewModel.cs
2015-12-06 10:56:21 -08:00

36 lines
1.2 KiB
C#

using System.Windows;
using System.Windows.Input;
namespace Xunit.Runner.Wpf
{
class CommandBindings
{
public static DependencyProperty Registration = DependencyProperty.RegisterAttached(
nameof(Registration), typeof(CommandBindingCollection), typeof(CommandBindings), new PropertyMetadata(null, OnRegistrationChanged));
public static void SetRegistration(UIElement element, CommandBindingCollection value)
{
if (element != null)
{
element.SetValue(Registration, value);
}
}
public static CommandBindingCollection GetRegistration(UIElement element)
=> (element != null ? (CommandBindingCollection)element.GetValue(Registration) : null);
private static void OnRegistrationChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
UIElement element = sender as UIElement;
if (element != null)
{
CommandBindingCollection bindings = e.NewValue as CommandBindingCollection;
if (bindings != null)
{
element.CommandBindings.AddRange(bindings);
}
}
}
}
}