Intersoft ClientUI Documentation
HybridRoutedCommand Class
Members  See Also  Send Feedback
Intersoft.Client.Framework.Input Namespace : HybridRoutedCommand Class






Defines a command that implements IHybridCommand and is routed through the element tree.

Object Model

HybridRoutedCommand Class

Syntax

Visual Basic (Declaration) 
<TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")>
Public Class HybridRoutedCommand 
   Inherits RoutedUICommand
   Implements IHybridCommand 
Visual Basic (Usage)Copy Code
Dim instance As HybridRoutedCommand
C# 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
public class HybridRoutedCommand : RoutedUICommand, IHybridCommand  
Delphi 
public class HybridRoutedCommand = class(RoutedUICommand, IHybridCommand)
JScript 
TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")
public class HybridRoutedCommand extends RoutedUICommand implements IHybridCommand 
Managed Extensions for C++ 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
public __gc class HybridRoutedCommand : public RoutedUICommand, IHybridCommand  
C++/CLI 
[TypeConverterAttribute("Intersoft.Client.Framework.Input.CommandConverter, Intersoft.Client.Framework, Version=3.0.5000.1, Culture=neutral, PublicKeyToken=c3d9b11444163e76")]
public ref class HybridRoutedCommand : public RoutedUICommand, IHybridCommand  

Remarks

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.

Inheritance Hierarchy

System.Object
   Intersoft.Client.Framework.Input.RoutedCommand
      Intersoft.Client.Framework.Input.RoutedUICommand
         Intersoft.Client.Framework.Input.HybridRoutedCommand
            Intersoft.Client.Framework.Input.HybridDelegateCommand

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.