Intersoft.Client.Framework.Input Namespace : HybridCommandBinding Class |
Defines a command that implements IHybridCommand which passes CanQueryState and QueryStatus as delegated method.
Public Class HybridCommandBinding Inherits CommandBinding
Dim instance As HybridCommandBinding
public class HybridCommandBinding : CommandBinding
public ref class HybridCommandBinding : public CommandBinding
ClientUI extends the routed command model further by introducing hybrid routed command, a more advanced routed command that supports two kind of state synchronization behavior. In addition to the IsEnabled handling, HybridRoutedCommand can automatically synchronize the Visibility property of the command sources based on the value of the CanExecute in the event data.
The HybridRoutedCommand introduces a more intuitive commanding pattern by adding status querying capability on the top of execute querying mechanism.
Hybrid routed command is built on the top of routed command model that supports the commanding semantics such as the command, the command source, the command target, and the command binding. In addition, hybrid routed command exposes its own classes and object model to support additional features which includes HybridRoutedCommand, HybridCommandManager and a HybridCommandBinding class.
The HybridRoutedCommand class is derived from RoutedUICommand, and extended with IHybridCommand interface which expose two members, CanQueryStatus and QueryStatus, which are explained later in this topic.
You can use HybridRoutedCommand in the same way as you would do in RoutedCommand. The following code example shows how to setup a tool bar button to execute a HybridRoutedCommand.
XAML |
Copy Code
|
---|---|
<Grid x:Name="LayoutRoot"> <Intersoft:CommandManager.CommandBindings> <Intersoft:CommandBindingCollection> <Intersoft:CommandBinding Command="Commands:EditingCommands.Bold" CanExecute="BoldCmdCanExecute" Executed="BoldCmdExecuted"/> <Intersoft:HybridCommandBinding Command="Commands:EditingCommands.Bold" CanExecute="BoldCmdCanExecute" Executed="BoldCmdExecuted"/> </Intersoft:CommandBindingCollection> </Intersoft:CommandManager.CommandBindings> <Intersoft:DockPanel Name="dockPanel1" FillChildMode="Custom"> <Intersoft:UXToolBar Name="toolBar1" Intersoft:DockPanel.Dock="Top"> <Intersoft:UXToolGroup> <Intersoft:UXToolBarButton Name="btn_Bold" Command="Commands:EditingCommands.Bold" DisplayMode="Image" Icon="../Images/BoldHS.png" ToolTipService.ToolTip="Bold"/> <Intersoft:UXToolBarButton Name="btn_Italic" Command="Commands:EditingCommands.Italic" DisplayMode="Image" Icon="../Images/ItalicHS.png" ToolTipService.ToolTip="Italic"/> </Intersoft:UXToolGroup> </Intersoft:UXToolBar> <Intersoft:UXTextBox Name="textBox1" Text="Type your text here..." Intersoft:DockPanel.IsFillElement="True" /> </Intersoft:DockPanel> </Grid> |
As shown in the above example, the standard CommandBinding is required in addition to the HybridCommandBinding definition because the hybrid routed command is fundamentally built upon the routed command model.
The following code example shows the event handler for the CanExecute and Executed routed event for the CommandBinding associated to the Bold command.
C# |
Copy Code
|
---|---|
private void BoldCmdCanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; } private void BoldCmdExecuted(object sender, ExecutedRoutedEventArgs e) { string command = ((RoutedCommand)e.Command).Name; string target = ((FrameworkElement)e.OriginalSource).Name; MessageBox.Show("The " + command + " command has been invoked on target object " + target); } |
A version of hybrid command that supports MVVM Pattern is also provided. Using HybridDelegateCommand, you can define the command in the view model and bind it to the view. For more information about using command with MVVM Pattern, see MVVM Pattern Overview.
For more information about hybrid commands, see Hybrid Commands.
System.Object
Intersoft.Client.Framework.Input.CommandBinding
Intersoft.Client.Framework.Input.HybridCommandBinding
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2