Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Using wpg in applications

DenisVuyka edited this page Feb 27, 2011 · 3 revisions

Using WPG in Applications

Assembly Reference Information

  • Assembly: System.Windows.Controls.WpfPropertyGrid.dll
  • Location: [Installation Folder]\WpfPropertyGrid

XAML Markup Information

Usage Sample

Window1.xaml

<Window 
x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:pg="http://schemas.denisvuyka.wordpress.com/wpfpropertygrid"
Title="Window1" Height="300" Width="300">
<Grid>
  <pg:PropertyGrid x:Name="propertyGrid"/>
</Grid>
</Window>

Window1.xaml.cs

using System.Windows;
using System.Windows.Controls;

namespace WpfApplication1
{
  /// <summary>
  /// Interaction logic for Window1.xaml
  /// </summary>
  public partial class Window1 : Window
  {
    InitializeComponent();
    // Assign a Button instance as a SelectedObject
    this.propertyGrid.SelectedObject = new Button();
  }
}

PropertyGrid control properties that are frequently used from XAML

  • CategoryComparer

This property is used to sort Category items when PropertyGrid is set to Categorized mode.

  • Editors

This property is typically set in markup to customize the value editors and their styles, but it can also be modified from code behind in more dynamic scenarios. Contains Type, Property and Category editors.

  • HasCategories

This is a read-only property determining whether at least one category item is present within the PropertyGrid control. Used for conditional visibility, styling and templating. Can be used by external components either from XAML or code.

  • HasProperties

This is a read-only property determining whether at least one property item is present within the PropertyGrid control. Used for conditional visibility, styling and templating. Can be used be external components either from XAML or code.

  • Layout

This property is used to define the whole View of the properties or categories. It can be one of the default layouts (Alphabetical, Categorized or Tabbed Layout) or fully custom implementation.

  • PropertyComparer

This property is used to sort property items. When PropertyGrid is set to Categorized mode sorting is applied to each category separately.

  • PropertyDisplayMode

This property defines a set of properties to be displayed within PropertyGrid (all properties, dependency properties only or CLR properties only). The default value is "All".

  • PropertyFilter

This property is used to get or set current property filter string.

  • PropertyFilterVisibility

This property is used to toggle the visibility of a property filter box. The default value is "Visible".

  • SelectedObject

This property is typically set in code, but can be set through markup using the {x:Static} XAML markup extension or through data binding.

  • SelectedObjects

This property is typically set in code, but can be set through markup using the {x:Static} XAML markup extension or through data binding.

  • ShowAttachedProperties

This property is used to show or hide Attached Properties. The default value is "False".

  • ShowDependencyProperties

This property is used to show or hide Dependency Properties alongside the plain CLR ones. The default value is "True".

  • ShowReadOnlyProperties

This property is used to show or hide Read-Only properties. The default value is "False".