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






Provides a reference to Command object for Binding purpose.

Object Model

CommandReference Class

Syntax

Visual Basic (Declaration) 
Public Class CommandReference 
   Inherits System.Windows.FrameworkElement
Visual Basic (Usage)Copy Code
Dim instance As CommandReference
C# 
public class CommandReference : System.Windows.FrameworkElement 
Delphi 
public class CommandReference = class(System.Windows.FrameworkElement)
JScript 
public class CommandReference extends System.Windows.FrameworkElement
Managed Extensions for C++ 
public __gc class CommandReference : public System.Windows.FrameworkElement 
C++/CLI 
public ref class CommandReference : public System.Windows.FrameworkElement 

Remarks

ClientUI is specifically engineered to address a number of challenges in building MVVM pattern applications that target both Silverlight and WPF platform.

ClientUI streamlines the application development using MVVM pattern with commanding pattern which has been extended to work in both platforms. One of the techniques is using CommandReference to map the input binding to a command.

CommandReference is a multi-purpose component that facilitates declarative XAML binding between an InputBinding and a command in a MVVM pattern application. Although it can be used in various MVVM scenarios, one of the most common usage is to bind an InputBinding such as MouseBinding or KeyBinding, to a command that defined in the ViewModel.

The following code example shows a contact list page with tool bar buttons using MVVM pattern that is compatible with Silverlight and WPF.

XAML Copy Code
<Intersoft:UXPage 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:Intersoft="http://intersoft.clientui.com/schemas"
        xmlns:local="clr-namespace:Contacts_MVVM.ViewModels"
        x:Class="Contacts_MVVM.Views.ContactsView" 
        d:DesignWidth="640" d:DesignHeight="480" 
        x:Name="contactsViewPage" Title="My Contacts">

    <Intersoft:UXPage.Resources>
        <local:ContactsViewModel x:Key="ContactsViewModelSource" d:IsDataSource="true"/>
    </Intersoft:UXPage.Resources>

    <Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource ContactsViewModelSource}}">
        <Grid.Resources>
            <Intersoft:CommandReference x:Key="AddCommand" Command="{Binding AddCommand}"/>
            <Intersoft:CommandReference x:Key="EditCommand" Command="{Binding EditCommand}"/>
            <Intersoft:CommandReference x:Key="DeleteCommand" Command="{Binding DeleteCommand}"/>
        </Grid.Resources>
        <Intersoft:CommandManager.InputBindings>
            <Intersoft:InputBindingCollection>
                <Intersoft:KeyBinding Command="{StaticResource AddCommand}" Gesture="Ctrl+Shift+A"/>
                <Intersoft:KeyBinding Command="{StaticResource EditCommand}" Gesture="Ctrl+Shift+E"/>
                <Intersoft:KeyBinding Command="{StaticResource DeleteCommand}" Gesture="Ctrl+Shift+X"/>
            </Intersoft:InputBindingCollection>
        </Intersoft:CommandManager.InputBindings>
        <Intersoft:DockPanel FillChildMode="Custom">
            <Intersoft:UXToolBar Intersoft:DockPanel.Dock="Top">
                <Intersoft:UXToolGroup>
                    <Intersoft:UXToolBarButton Command="{Binding AddCommand}" Content="Add New Contact" ToolTipService.ToolTip="Add a new contact (Ctrl + Shift + A)"/>
                    <Intersoft:UXSeparator/>
                    <Intersoft:UXToolBarButton Command="{Binding EditCommand}" Content="Edit Contact" ToolTipService.ToolTip="Edit selected contact (Ctrl + Shift + E)" />
                    <Intersoft:UXToolBarButton Command="{Binding DeleteCommand}" Content="Delete Contact" ToolTipService.ToolTip="Delete selected contact (Ctrl + Shift + X)"/>
                </Intersoft:UXToolGroup>
            </Intersoft:UXToolBar>
            <Intersoft:UXListBox ItemsSource="{Binding Contacts}" ItemTemplate="{StaticResource ContactViewTemplate}" SelectedItem="{Binding Path=SelectedItem, Mode=TwoWay}"/>
        </Intersoft:DockPanel>
    </Grid>
<Intersoft:UXPage>

For a complete walkthrough of using commanding with MVVM pattern, see Walkthrough: Use Command Binding and Key Binding with MVVM Pattern.

For more information about unified development model in ClientUI, see Unified Development Model.

Inheritance Hierarchy

System.Object
   System.Windows.DependencyObject
      System.Windows.UIElement
         System.Windows.FrameworkElement
            Intersoft.Client.Framework.Input.CommandReference

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.