Skip to main content
A newer version of this page is available. .

Property Menu

  • 2 minutes to read

Property Menu Overview

The PropertyGridControl can show menu for each property. To enable or disable property menu, use the PropertyDefinition.ShowMenuButton property.

property grid menu.png

By default, the PropertyGridControl displays the following menu items.

  • The Refresh button invokes a bound property getter to refresh the value displayed in PropertyGridControl. This is particularly useful when editing objects that don’t support change notifications.
  • The Reset button resets a property to its initial value and will be enabled when the CanResetValue method of a corresponding the property descriptor returns true. To enable the Reset button for standard non-dependency properties, specify the DefaultValue attribute.

The PropertyGridControl allows you to customize property menus. To add new menu items or remove the existing ones, use the following properties.

Note

The PropertyDefinition.MenuCustomizations property has higher precedence than the PropertyGridControl.MenuCustomizations property.

Adding Custom Menu Items

To add a new property menu item, specify the required bar item within the MenuCustomizations collection. To learn more about available bar items, see The List of Bar Items and Links.

The CollectionAction.Index attached property specifies the position of the new item.

The following example demonstrates how to add a custom menu item to a property definition and specify the new item’s position.

<Window   ...
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    xmlns:dxprg="http://schemas.devexpress.com/winfx/2008/xaml/propertygrid">
...
<dxprg:PropertyDefinition Type="sys:String">
    <dxprg:PropertyDefinition.MenuCustomizations>
        <dxb:BarCheckItem Name="checkItem1" Content="Checked" IsChecked="True" dxb:CollectionAction.Index="0" />
    </dxprg:PropertyDefinition.MenuCustomizations>
</dxprg:PropertyDefinition>

pgrid_custommenu

Removing Existing Menu Items

To remove an existing item from the property menu, add a RemoveAction object to the MenuCustomizations collection. The RemoveAction.ElementName property specifies the item that you want to remove. The static BarItemNames class stores the names of the default items.

The following example demonstrates how to remove a default menu item from the property menu.

<Window   ...
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    xmlns:dxprg="http://schemas.devexpress.com/winfx/2008/xaml/propertygrid">
...
<dxprg:PropertyDefinition Type="sys:String">
    <dxprg:PropertyDefinition.MenuCustomizations>
        <dxb:RemoveAction ElementName="{x:Static dxprg:BarItemNames.Refresh}" />
    </dxprg:PropertyDefinition.MenuCustomizations>
</dxprg:PropertyDefinition>
See Also