Back to Devexpress

BarItemLinkActionBase.ItemLinkIndex Attached Property

wpf-devexpress-dot-xpf-dot-bars-dot-baritemlinkactionbase.md

latest6.6 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Wpf.Core

Declaration

See GetItemLinkIndex(DependencyObject) and SetItemLinkIndex(DependencyObject, Int32).

Returns

TypeDescription
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.

Example

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

View Example: Customize the GridControl'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.

xaml
<dxg:TableView.ColumnMenuCustomizations>
    <dxb:BarCheckItem Content="Checked" IsChecked="True" dxb:BarItemLinkActionBase.ItemLinkIndex="0"/>
    <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1"/>
</dxg:TableView.ColumnMenuCustomizations>

In Code

Handle the ShowGridMenu event.

xaml
<dxg:TableView ShowGridMenu="ShowGridMenu"/>
csharp
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);
    }
}
vb
Sub ShowGridMenu(sender As Object, e As GridMenuEventArgs)
    If e.MenuType = GridMenuType.Column Then
        Dim item1 As BarCheckItem = New BarCheckItem() With {.Content = "Checked", .IsChecked = True}
        BarItemLinkActionBase.SetItemLinkIndex(item1, 0)
        e.Customizations.Add(item1)
        Dim item2 As BarItemLinkSeparator = New BarItemLinkSeparator()
        BarItemLinkActionBase.SetItemLinkIndex(item2, 1)
        e.Customizations.Add(item2)
    End If
End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ItemLinkIndex attachedproperty.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-rich-text-editor-customize-context-menu/CS/ContextMenuCustomization/MainWindow.xaml#L42

xml
<dxre:RemoveRichEditCommandAction Id="{x:Static dxrecore:RichEditCommandId.CutSelection}" />
<dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="0">
    <dxb:BarButtonItemLink.BarItemName>

wpf-spreadsheet-customize-context-menu/CS/MenuCustomization/MainWindow.xaml#L36

xml
<dxsps:SpreadsheetMenuCustomization MenuType="Cell">
    <dxb:BarButtonItemLink dxb:BarItemLinkActionBase.ItemLinkIndex="0">
        <dxb:BarButtonItemLink.BarItemName>

how-to-customize-a-grids-context-menu-e1925/CS/Window1.xaml#L12

xml
<dxg:TableView.ColumnMenuCustomizations>
    <dxb:BarCheckItem Content="BarCheckItem" dxb:BarItemLinkActionBase.ItemLinkIndex="0" CheckedChanged="BarCheckItem_CheckedChanged"/>
    <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1"/>

wpf-dock-layout-manager-use-events-to-dynamically-customize-context-menus/CS/DockManager_MenuCustomization/Window1.xaml.cs#L39

csharp
actionAddSeparator.ItemLink = new BarItemLinkSeparator();
actionAddSeparator.ItemLinkIndex = 1;

wpf-dock-layout-manager-use-events-to-dynamically-customize-context-menus/VB/DockManager_MenuCustomization/Window1.xaml.vb#L31

vb
actionAddSeparator.ItemLink = New BarItemLinkSeparator()
actionAddSeparator.ItemLinkIndex = 1
' Add the actions to the ActionList

See Also

BarItemLinkActionBase Class

BarItemLinkActionBase Members

DevExpress.Xpf.Bars Namespace