Version

Working with Commands (xamPropertyGrid)

Topic Overview

Purpose

This topic explains how to perform different operations with the control using commands.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic explains the features supported by the control from developer perspective.

This topic provides an overview of the visual elements of the control.

Commands Introduction

Commands summary

The xamPropertyGrid control provides a lot of commands for activating different features. You can find the full list of commands in the PropertyGridCommandType enumeration.

You can invoke commands by instantiating the PropertyGridCommandSource type. The following commands however require a PropertyGridPropertyItem parameter to be supplied and they are invoked by instantiating the PropertyGridPropertyItemCommandSource type:

  • AddListEntry

  • RemoveListEntry

  • ResetPropertyValue

  • CreateExpandableObject

  • ShowOptionsMenu

Code Example: Invoking a Command in XAML

Description

The following code snippet shows how to invoke a command in XAML on the xamPropertyGrid control using a button. The code snippet assumes you have a reference to a xamPropertyGrid instance named "xamPropertyGrid1".

Code

In XAML:

<Page
  …
  xmlns:ig="http://schemas.infragistics.com/xaml"
  xmlns:igPrim="http://schemas.infragistics.com/xaml/primitives"
  …>
<Button
  Content="Sort By Category"
  ig:Commanding.CommandTarget="{Binding ElementName=xamPropertyGrid1}">
  <ig:Commanding.Command>
    <igPrim:PropertyGridCommandSource
      EventName="Click"
      CommandType="SortByCategory" />
  </ig:Commanding.Command>
</Button>

Code Example: Invoking a Command in XAML with Parameter

Description

The following code snippet shows how to invoke a command with parameter in XAML on the xamPropertyGrid control using a button. The code snippet assumes you have a reference to a xamPropertyGrid instance named "xamPropertyGrid1".

Code

In XAML:

<Page
  …
  xmlns:ig="http://schemas.infragistics.com/xaml"
  xmlns:igPrim="http://schemas.infragistics.com/xaml/primitives"
  …>
<Button
  Content="Reset Current Property Value"
  ig:Commanding.CommandTarget="{Binding ElementName=xamPropertyGrid1}">
  <ig:Commanding.Command>
    <igPrim:PropertyGridPropertyItemCommandSource
      EventName="Click"
      CommandType="ResetPropertyValue"
      ParameterBinding="{Binding ElementName=xamPropertyGrid1, Path=SelectedItem}" />
  </ig:Commanding.Command>
</Button>

Code Example: Invoking a Command in Code

Description

The following code snippet shows how to invoke a command in code on the xamPropertyGrid control. The code snippet assumes you have a reference to a xamPropertyGrid instance named "xamPropertyGrid1".

Code

Following is the code that implements this example.

In C#:

using Infragistics.Controls.Editors;
using Infragistics.Controls.Editors.Primitives;
...
PropertyGridCommand cmd = new PropertyGridCommand(PropertyGridCommandType.SortByCategory);
cmd.Execute(this.xamPropertyGrid1);

In Visual Basic:

Import Infragistics.Controls.Editors
Import Infragistics.Controls.Editors.Primitives
...
Dim cmd As New PropertyGridCommand(PropertyGridCommandType.SortByCategory)
cmd.Execute(Me.xamPropertyGrid1)

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how the control identifies and displays expandable properties.

This topic explains how the control discovers properties on the selected object(s), generates the list of property items and how the process can be configured and customized.

This topic explains how to define default property value and how to customize the options menu.