Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ControlCommands.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System.Windows.Controls.Primitives;
4 using System.Windows.Input;
5 using System.Windows.Markup;
6 
7 namespace SiliconStudio.Presentation.Controls.Commands
8 {
9  /// <summary>
10  /// This class provides an instance of all commands in the namespace <see cref="SiliconStudio.Presentation.Controls.Commands"/>.
11  /// These instances can be used in XAML with the <see cref="StaticExtension"/> markup extension.
12  /// </summary>
13  public static class ControlCommands
14  {
15  /// <summary>
16  /// Initialize the static properties of the <see cref="ControlCommands"/> class.
17  /// </summary>
18  static ControlCommands()
19  {
20  ClearSelectionCommand = new RoutedCommand("ClearSelectionCommand", typeof(Selector));
21  CommandManager.RegisterClassCommandBinding(typeof(Selector), new CommandBinding(ClearSelectionCommand, OnClearSelectionCommand));
22  }
23 
24  /// <summary>
25  /// Clears the current selection of a text box.
26  /// </summary>
27  public static RoutedCommand ClearSelectionCommand { get; private set; }
28 
29  private static void OnClearSelectionCommand(object sender, ExecutedRoutedEventArgs e)
30  {
31  var selector = sender as Selector;
32  if (selector != null)
33  {
34  selector.SelectedItem = null;
35  }
36  }
37  }
38 }
This class provides an instance of all commands in the namespace SiliconStudio.Presentation.Controls.Commands. These instances can be used in XAML with the StaticExtension markup extension.