Bar

BarItemLinkActionBase.ItemLinkIndex Attached Property

Gets or sets the index of the bar item link in the object's collection of bar item links. This is an attached property.

Namespace: DevExpress.Xpf.Bars

Assembly: DevExpress.Xpf.Core.v20.1.dll

Declaration

Returns

Type Description
Int32

The index of the bar item link in the object's collection of bar item links.

Remarks

This property is in effect for the BarManagerActionContainer.Actions collection's BarItem and BarItemLink descendants.

Examples

The following example demonstrates how to add a custom menu item to a grid column's context menu:

In XAML

Add a bar item (for example, BarCheckItem) to the DataViewBase.ColumnMenuCustomizations collection and specify item properties. Attach the BarItemLinkActionBase.ItemLinkIndex property to this item to insert it into a specific position.

<dxg:TableView.ColumnMenuCustomizations>
    <dxb:BarCheckItem Name="checkItem1" Content="Checked" IsChecked="True" dxb:BarItemLinkActionBase.ItemLinkIndex="0" />
    <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1" />
</dxg:TableView.ColumnMenuCustomizations>
private void customItem1_CheckedChanged(object sender, ItemClickEventArgs e) {
    // do something...
}

In Code

Handle the ShowGridMenu event.

<dxg:TableView ShowGridMenu="ShowGridMenu" />
void ShowGridMenu(object sender, GridMenuEventArgs e) {
    if (e.MenuType == GridMenuType.Column) {
        BarCheckItem item1 = new BarCheckItem { Content = "Checked", IsChecked = true };
        BarItemLinkActionBase.SetItemLinkIndex(item1, 0);
        e.Customizations.Add(item1);
        BarItemLinkSeparator item2 = new BarItemLinkSeparator();
        BarItemLinkActionBase.SetItemLinkIndex(item2, 1);
        e.Customizations.Add(item2);
    }
}
See Also