AdvGrid is based on the abstract class AdvTabularControl (which also serves as the base class for AdvTree.) AdvTabularControl itself is derived on System.Windows.Controls.Control. It is NOT based on ItemsControl. However, because ItemsControl provides a familiar programming model, we have as much as seemed reasonable made AdvTabularControl (and therefore AdvGrid) work and behave like ItemsControl. Generally speaking, if you understand ItemsControl you will understand the essentials of AdvGrid.

The minimum requirement for adding an AdvGrid to your application is a data source for the rows which implements IEnumerable. Simply bind your data source to the grid’s ItemsSource property. Each object in the enumeration becomes the DataContext for a row in the grid. The object’s properties are the source for the content of the row’s cells. The mapping between the object’s properties and the grid’s columns can be made automatically or you can define the mapping yourself if you require more control that what is provided by default.

Beyond setting up a data source, some of the more common settings to explore are:

  • Set property VirtualizationMode = Recycling to enable both row and cell virtualization.
  • Set IsByRowEditingEnabled = true to put the grid into by-row editing mode.
  • Set CanUserAddRow = true to cause a “placeholder” row to be added to the bottom of the grid which the user can use to add a new row.
  • Provide a DataTemplate as value for RowDetailsTemplate to create a details section for your rows.
  • Use property RowDetailsShowMode to specify  when row details are made visible.
  • Set AutoGenerateColumns = true to have columns automatically generated. Handle the routed event AutoGeneratingColumns to customize a column when it is being automatically generated.
  • Set ScrollMode = ByItem to enable scroll-by-item.
  • Use SelectionMode to specify whether Single, Multiple or Extended selection mode is active.
  • Use SelectionUnit to specify whether cells, rows or cells and rows via the row headers are selectable by user.
  • ColumnHeaderClickBehavior specifies what happens when the user clicks on a column header.
  • Set AllowColumnReorder = true to allow the user to re-order the columns using drag and drop.
  • Set IsContextMenuEnabled = true to enable a built-in context menu that allows the user to (optionally) sort, group, pin and hide/show individual columns.
  • RowHeaderWidth specifies the width of the row headers.
  • Filter the items that are displayed with a Predicate<object> set as value for the grid’s Filter property.
  • Display your items in groups based on column values by setting the GroupByLevel of the appropriate column definition.
  • Set ShowColumnGroupingPanel = true to display a panel into which the user can drag column headers to cause the grid to group the items by that column’s data.
  • Set CanUserDeleteItem to allow the user to delete rows using the delete key.
  • And many more…

A good place to start exploring AdvGrid, other than this document, is the AdvGridSample application which is included in the DotNetBar installation. Here is a screen shot:

AdvGrid Sample App

AdvGrid, AdvGridRow and AdvGridCell

AdvGridRow is the native container type for items placed into the grid. New containers are obtained from the grid’s GetContainerFromItemOverride method. It is possible to override this method and supply your own row control type, but it must derive from AdvGridRow. Similarly, AdvGridCell is the native container for cell data. When a new cell is required, it is obtained via the parent row’s CreateCell method. This too can be overridden to provide your own cell control.

Both AdvGridRow and AdvGridCell have Connect and Disconnect methods. The first is called by the system to prepare the row or cell for the data item that it is being used to display. The latter is called when the row is being virtualized and is used to release the control from the data object and make it available to connect to another. Inheritors of either AdvGridRow or AdvGridCell may need to override these methods if they define new dependency properties of their own, for example, or require some other custom connection logic.

AdvGrid is designed to look and act as much like ItemsControl as possible, but it does not have an ItemContainerGenerator. Instead, it has an ItemContainerManager (specifically, AdvGridItemContainerManager) the purpose of which is to manage row creation and the placement of the rows into the visual tree, and virtualization.

Columns

The grid’s columns are defined by a collection of ColumnDefinition objects. The collection is set and/or accessed through the grid’s ColumnDefinitions property. ColumnDefinitions is a dependency property so it can participate in data binding. Also, both ColumnDefinitions and ColumnDefinition are derived from System.Windows.FrameworkContentElement which allows them to inherit the grid’s data context and use bindings which refer to named elements in the visual tree.

The column definitions can be automatically generated from the data object set as the value of ItemsSource. If the object is an instance of System.Data.DataView then the columns are generated from the Columns in its Table. If the object is an enumeration of objects, then the columns are generated using the first object in the list. The public properties of this object are discovered using reflection. By default, a column is created for each public property. The column header will be the property’s Name, unless the property definition is decorated with a DisplayName attribute (System.ComponentModel.DisplayNameAttribute.) To prevent a column from being created for a public property, decorate it with a DisplayName attribute and set the value to null.

By default columns will be auto generated if the column definitions are not otherwise provided for at the time the grid loads. To disable auto generation of columns, set property AutoGenerateColumns = false.

While auto column generation can be convenient if you are satisfied with the defaults, far more control is available if you define the columns explicitly. Columns can be defined in Xaml or code. Here is an example in Xaml (taken from the AdvGridSample application):

<dc:ColumnDefinitionCollection x:Key="CustomersGridColumnDefinitions" Padding="10" HorizontalContentAlignment="Center">
    <dc:ColumnDefinition Header="Name" BindingMemberPath="Name" CellIsEditable="True" AutoSizeToFitContent="True" CellHorizontalContentAlignment="Left" />
    <dc:ColumnDefinition Header="Age" BindingMemberPath="Age" CellIsEditable="True" AutoSizePadding="25">
        <dc:ColumnDefinition.EditorSettings>
            <dc:NumericEditorSettings IsButtonHighlightedOnMouseOver="True" MinValue="0" MaxValue="120" IsInCellEditingEnabled="False" EnforceMinMax="True" />
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
    <dc:ColumnDefinition Header="Gender" BindingMemberPath="Gender" CellIsEditable="True" AutoSizePadding="20">
        <dc:ColumnDefinition.EditorSettings>
            <dc:EnumEditorSettings IsButtonHighlightedOnMouseOver="True" IsInCellEditingEnabled="True" />
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
    <dc:ColumnDefinition Header="Income" BindingMemberPath="Income" CellIsEditable="True" AutoSizePadding="20">
        <dc:ColumnDefinition.EditorSettings>
            <dc:NumericEditorSettings IsButtonHighlightedOnMouseOver="True" MinValue="0" StringFormat="C" />
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
    <dc:ColumnDefinition Header="Is Married" BindingMemberPath="IsMarried" CellIsEditable="True" />
    <dc:ColumnDefinition Header="Can Contact" BindingMemberPath="CanContact" CellIsEditable="True">
        <dc:ColumnDefinition.EditorSettings>
            <dc:BooleanEditorSettings Type="DropDown" DisplayNameFalse="Never" DisplayNameTrue="Any Time" IsButtonHighlightedOnMouseOver="False" IsInCellEditingEnabled="False" />
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
    <dc:ColumnDefinition Header="Best Time" BindingMemberPath="BestTime" CellIsEditable="True" StringFormat="T" AutoSizePadding="20">
        <dc:ColumnDefinition.EditorSettings>
            <dc:TimeOfDayEditorSettings />
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
    <dc:ColumnDefinition Header="Credit Card" BindingMemberPath="CreditCard" CellIsEditable="True" BeginEditTriggerMode="ClickSelected">
        <dc:ColumnDefinition.EditorSettings>
            <dc:DataFormEditorSettings PropertyType="{x:Type local:CreditCard}" DialogWindowTitle="Credit Card Properties" DisplayMemberPath="Issuer">
                <dc:DataFormEditorSettings.FieldDescriptors>
                    <dc:DataFormFieldDescriptor DisplayName="Name:" PropertyName="NameOnCard" />
                    <dc:DataFormFieldDescriptor DisplayName="Card Issuer:" PropertyName="Issuer">
                        <dc:DataFormFieldDescriptor.EditorSettings>
                            <dc:EnumEditorSettings />
                        </dc:DataFormFieldDescriptor.EditorSettings>
                    </dc:DataFormFieldDescriptor>
                    <dc:DataFormFieldDescriptor DisplayName="Expiration Date:" PropertyName="ExpirationDate">
                        <dc:DataFormFieldDescriptor.EditorSettings>
                            <dc:EditorSettings StringFormat="MMM, yyyy" Mask="LLL, 0000" />
                        </dc:DataFormFieldDescriptor.EditorSettings>
                    </dc:DataFormFieldDescriptor>
                    <dc:DataFormFieldDescriptor DisplayName="Number:" PropertyName="CardNumber">
                        <dc:DataFormFieldDescriptor.EditorSettings>
                            <dc:EditorSettings Mask="0000-0000-0000-0000"/>
                        </dc:DataFormFieldDescriptor.EditorSettings>
                    </dc:DataFormFieldDescriptor>
                </dc:DataFormEditorSettings.FieldDescriptors>
            </dc:DataFormEditorSettings>
        </dc:ColumnDefinition.EditorSettings>
    </dc:ColumnDefinition>
</dc:ColumnDefinitionCollection>

ColumnDefinitionCollection

Following is a list of the properties of ColumnDefinitionCollection. Note that several properties of ColumnDefinitionCollection have been mapped to AdvGrid for convienence. All of these properties are dependency properties and hence can be data bound.

  • AllowColumnReorder
  • AllowColumnResize
  • AlternationCount
  • BorderBrush
  • BorderThickness
  • CellPadding –
  • CellStyle –
  • ColumnStyle
  • ColumnsPresenterStyle
  • GridLineBrush
  • GridLineWidth
  • HeaderBackground
  • HeaderClickBehavior
  • HeaderClickMode
  • HorizontalAlignment
  • HorizontalContentAlignment
  • IsContextMenuEnabled
  • Padding – This sets the padding aplied to all the column headers.
  • ShowGridLines -
  • ShowHeader
  • VerticalContentAlignment

ColumnDefinition

ColumnDefinition exports a single event: PropertyChanged. The handler type for PropertyChanged is DependencyPropertyChangedEventHandler.

The following CLR properties are exposed on ColumnDefinition:

  • AutoSizePadding – A double which is added to a cell’s desired size when performing auto size for the column.
  • AutoSizeToFitContent – When true, the column’s width will automatically be increased as needed so that cells’ content is fully visible. Ignored if the column’s Width is not Auto.
  • Binding – Defines the binding used for a cell’s content property. By default this value is set at runtime based on the value of BindingMemberPath.
  • Id – A string. Not used. Provided for client use only.
  • IndexInParent – Gets the index of the column within the parent ColumnDefinitionCollection.
  • ParentCollection – Access a reference to the ColumnDefinitionCollection which contains the column definition.

Here is the list of dependency properties available on ColumnDefinition:

  • AllowColumnResize
  • Background
  • BeginEditTriggerMode
  • BindingMemberPath
  • CellContentTemplate -
  • CellEditorStyle
  • CellEditTemplate
  • CellForeground
  • CellHorizontalContentAlignment
  • CellIsEditable
  • CellIsSelectable
  • CellPadding
  • CellStyle
  • CellVerticalContentAlignment
  • ColumnSort
  • EditorSettings
  • GridLineBrush
  • GridLineWidth
  • Header
  • HeaderTemplate
  • HeaderBackground
  • HeaderBorderThickness
  • HeaderClickBehavior
  • HeaderClickMode
  • HorizontalContentAlignment
  • IsCellSelectedWithin
  • IsLocked
  • IsSelectable
  • IsSelected
  • Pin
  • Padding
  • PresenterStyle
  • ShowHeader
  • SortPriorityLevel
  • StringFormat
  • Width
  • VerticalContentAlignment
  • Visibility

Editing

To enable in cell editing, set CellIsEditable = true on the corresponding column definition. Alternately, property IsEditable on AdvGridCell can be set, through a style setter or directly. Nothing else is required to enable editing with the default editor, which is basically a text box. (Except for Booleans and enumerations. The default editor for bool values is a check box. For enums it is a combo box.)

Actual editing is performed by a ContentEditingControl which is embedded in the default Template for AdvGridCell. The content editing control is also responsible for displaying the cell’s content when not being edited.

There are several built-in editors, in addition to the default editor, each of which targets a specific data types. Assigning one of these editors to a column or cell is simply a matter of setting property EditorSettings to an instance of the class, derived from DevComponents.WPF.Controls.EditorSettings, which maps to the desired editor.

All built-in editors, including the default editor, have a set of options which are exposed as properties of the corresponding EditorSettings class.

For examples in Xaml, see the Xaml example for ColumnDefinitionCollection above.

If none of the built-in editors satisfies your requirements, a custom editor can be created by defining a new Style for the EditingContentControl. The style can be applied by setting it as the value of the property CellEditorStyle of the column definition, or as the value of property EditorStyle of the AdvCellControl. The EditorSettings class also has a property EditorStyle. More information about EditingContentControl is provided below.

EditorSettings

EditorSettings is based on System.Attribute, making it possible to define and customize a property’s editor directly on the property definition itself.

Following are the properties defined on the base class EditorSettings. Each of these properties represents an option common to all or most of the built-in editors. An important thing to note is that the control which does the editing (an instance of EditingContentControl) is also responsible for presenting the cell’s content when it is not in edit mode. For this reason, some of these properties affect the cell’s content when not in edit mode.

  • AlwaysShowTextBox – Primarily used when the editor has a button, determines whether the button is sized to occupy the entire cell or only a portion of it, leaving room for a text box containing the value text.
  • AutoComplete – An enumeration of type AutoCompleteOptions which defines auto complete options for text based editing. AutoCompleteOptions has the Flags attribute set. Possible values are:
    • Off – Auto complete is not enabled. This is the default.
    • ReadOnly – Auto complete is enabled. Only values in the auto complete list are allowed.
    • FreeText – Auto complete is enabled. The user is allowed to enter any text.
    • DontConvertCase – When auto complete is enabled, suggestions are case sensitive.
  • AutoCompleteList – Provides a list of possible values for auto complete. Required if auto complete is enabled.
  • DisplayMemberPath – If a cell’s data object is a complex object (i.e. it has properties of its own) then this property can be used to identify the path to the property which defines the text to display for the cell.
  • EditorStyle – A Style which, if set, is applied to the EditingContentControl.
  • EditorStyleResourceKey – A string which is the key of a discoverable resource defining a Style which is applied to the EditingContentControl. This property is specifically intended for when the EditorSettings are being applied as an Attribute to the property which serves as the data source for the cell/column.
  • IsInCellEditingEnabled – Determies whether the user can edit the cell’s value directly in the text box.
  • IsButtonHighlightedOnMouseOver – When true, buttons are highlighted when the mouse is over them.
  • Mask – A string which defines a mask to use on the cell’s string value. For more information see MaskedTextProvider documentation on MSDN.
  • NullValueDisplayValue – Specifies string to display for the null value.
  • PropertyType – The Type of the property being edited. By default, this value is obtained at run-time using reflection.
  • StringFormat – A format string applied to the cell’s string value.
  • TypeConverter – A System.ComponentModel.TypeConverter which if set is used to convert between the object being edited and the string representation of the object.
  • ValidationRules – A list of System.Windows.Controls.ValidationRule objects. Rules added to this list are added to the Binding which binds the cell’s content property.

Following are the editor settings classes for the built-in editors that are available at this time. They are all derived from EditorSettings.

BooleanEditorSettings

Used with the built-in Boolean editor. Defines the following properties:

  • DisplayNameTrue – The display string for the true value.
  • DisplayNameFalse – The display string for the false value.
  • IsNullable – Specifies whether null is a valid value. (The underlying property type must be Nullable<bool>)
  • Type – An enumeration specifying whether the editor is an inline check box or a drop down (combo box.) Possible values are InLineCheckBox and DropDown.

DataFormEditorSettings

Used with the built-in data form editor. It is a specialized version of DialogWindowEditorSettings which makes use of the DevComponents DataForm control. The properties defined by DataFormEditorSettings are:

  • FieldDescriptors – Gets a reference to a list of DataFormFieldDescriptor objects. You add the field descriptors for each property on the cell’s data source which you want to be editable. See Xaml example above.

DateEditorSettings

Used with the built-in date editor. The date editor is meant to edit the date portion of DateTime values. This editor makes use of the control System.Windows.Controls.Calendar. No additional properties are defined.

DialogWindowEditorSettings

Editor settings used by the built-in dialog window based editor. This editor allows you to define a Window type which is created and opened as a dialog window when the editor’s button is pressed. The window’s DataContext is set equal to the cell’s content. Additionally, if the window’s content property is null, it is also set equal to the cell’s content.  DialogWindowEditorSettings Defines the following properties:

  • CreateNewIfNull – When true, and the cell’s value is null, the editor will attempt to create a new instance of the data type before opening the dialog window. Requires that the data type has a parameterless constructor.
  • DialogWindowContentTemplate – A DataTemplate which if not null is set as value of the window’s ContentTemplate property.
  • DialogWindowStyle – A Style which if not null is set as the value of the window’s Style property.
  • DialogWindowTitle – A string which is used for the window’s Title.
  • DialogWindowType – A Type specifying the Window type to create and open. By default, this value is set to the type DevComponents.WPF.Controls.DialogWindow. DialogWindow is a window which defines a property Ok (Boolean) and has a command binding defined for the command ApplicationCommands.Close. The default template for this window has Ok and Cancel buttons.

EnumEditorSettings

Used with the built-in enum editor, which is based on the DevComponents EnumEditor control. EnumEditorSettings defines the following properties:

  • DisplayNames – A list of strings which are mapped, in order, to the enum values for display.
  • SeparatorToken – A string to use for separating a list of values when the enum type has the Flags attribute set.
  • Type – An enumeration with possible values DropDown and InLine.

NumericEditorSettings

Used with the built-in numeric editor. This editor can be used for numbers of any type. It makes use of the DevComponents control NumericSpinner which has repeat buttons for increasing and decreasing the value. NumericEditorSettings defines the following properties:

  • EnforceMinMax – When true, a rule is added to the ValidationRules list which enforces a value between MinValue and MaxValue.
  • Increment – The value that is added or subtracted from current value when a repeat button is clicked.
  • MaxValue – The value at which the increase repeat button becomes disabled.
  • MinValue – The value at which the decrease repeat button becomes disabled.
  • Precision – The precision with which to display floating point numbers.
  • RepeatDelay – The delay in milliseconds from when a repeat button is first pressed to when auto increment or decrement begins.
  • RepeatInterval – Specifies the milliseconds between click events of the repeat buttons when held down.

SelectorEditorSettings

Used with the built-in selector editor. The selector editor allows you to specify a list of possible values from which the user can select. SelectorEditorSettings defines the following properties:

  • PossibleValues – A list of objects from which the user can select. Note that you can customize the display by defining a DataTemplate targeting the data type of objects in this list.
  • Type – An enumeration which specifies whether the editor is a drop down or if the possible options are presented directly in the cell as radio buttons. Possible values are DropDown (the default) or InLine.

TimeOfDayEditorSettings

Used with the built-in editor for selecting a time of day. Makes use of the control DevComponents.WPF.Controls.TimeOfDaySpinner. This editor can edit properties of type System.DateTime and System.TimeSpan. Only the TimeOfDay portion of a DateTime is changed. TimeOfDayEditorSettings does not define any additional properties.

EditingContentControl

The way to create totally custom editors is to define a custom style for the EditingContentControl which does the actual editing. Each cell has an EditingContentControl embedded within it (assuming the default Template is in use for the cell.) The editing content control is also responsible for presenting the cell’s content when it is not being edited. When a cell goes into edit mode the editor’s IsEditing property is set to true, triggering whatever changes in the UI which are needed to support editing.

EditingContentControl is derived from System.Windows.Controls.ContentControl. By default, it’s Content property is bound to the containing cell’s Content property in a two way binding with the binding’s UpdateSourceTrigger set to Explicit, which enables control of when changes are actually committed to the underlying data source.

EditingContentControl Events

  • ChangeCommitted – A routed event raised after changes made by the user are committed to the underlying data source.
  • IsEditingChanging – A routed event raised when the value of IsEditing is changing. Setting the event arg’s Handled property to true prevents the value from changing.

EditingContentControl Methods

  • ClearPendingChanges – Reverses any changes made by the user which have not been committed to the underlying data source.
  • CommitPendingChanges – Causes all pending changes to be committed to the underlying data source.

EditingContentControl Properties

  • AlwaysShowTextBox – When true, the text box based editor is always shown. Is mapped to the EditorSettings property of the same name. The default value is false.
  • CommitOnContentChanged – When true all changes made by the user are immediately committed to the underlying data source.
  • ContentString – The actual value which is displayed by default by the editor. This property is bound directly to the Content property. The binding’s Converter property is set equal to the value of the editor settings ToStringValueConverter and the binding’s ConverterParameter is the editor settings itself. This design allows the editor to display and manipulate what is essentially two versions of the content being edited.
  • DialogWindowType – The Type of the window which is created and opened when IsDialogWindowOpen is set to true.
  • DropDownTemplate – Setting a value for this property automatically triggers the editor to include a toggle button that when checked opens a Popup. When set, the property specifies a ControlTemplate which is applied to a ContentControl that is a child of the Popup. The content of the ContentControl is bound to the Content property of the editor.
  • DropDownClosesOnClick – Determines whether the drop down closes automatically when a click event fires from within the drop down content. Applies when a value for DropDownTemplate is specified.
  • EditingTemplate – This is a ControlTemplate which is set as the editors Template when property IsEditing is true. This changes is performed via a trigger that is defined in the default EditingContentControl Style. The Template defined by the default style contains only a ContentPresenter when IsEditing is false. The EditingTemplate contains a TextBox.
  • EditingBackground – A Brush used as the background of the editor when IsEditing is true.
  • EditingBorderBrush – A Brush used for the control’s border when IsEditing is true.
  • EditingBorderThickness – A Thickness for the control’s border when IsEditing is true.
  • EditorSettings – Editor settings for the editor. By default, this value is bound to the EditorSettings property of the ColumnDefinition which defines the cell.
  • IsButtonHighlightedOnMouseOver – Determines whether the editor’s button, if it has one, is highlighted when the mouse is over it.
  • IsDialogWindowOpen – A boolean which, when set to true, causes the dialog window to be created and opened. When the dialog window closes this property is reset to false. Ignored if DialogWindowType is null.
  • IsEditing – A Boolean which determines whether the editor is in edit mode. Normally this value will be set by the containing cell control.
  • IsInCellEditingEnabled – A Boolean which determines whether the content can be edited directly in the cell, using a text box.

Virtualization

AdvGrid supports recycling virtualization. When virtualization is active and a row goes out of view, either by scrolling or by making the viewport smaller, the row itself is disconnected or disassociated from the data item for which it is the container. When a container has been disconnected from its data item in this manner it is said to have been “virtualized.” If scrolling, and a new item is coming into view, the container is then connected to the new item and displayed. When a container has been connected to a data item in this manner it is said to have been “recycled.” In the case where there are no disconnected containers to recycle, a new container is instantiated. In this case the container is said to have been “realized.”

Note: This “recycling” of the containers results in significantly better performance than so-called “standard” virtualization, where virtualized containers are left for the garbage collector and new container is instantiated for each item that comes into view. Because of this, we can see no reason to implement standard virtualization in AdvGrid. If you have a scenario where standard virtualization would be preferable to recycling, please let us know.

Virtualization offers two performance benefits: faster loading and reduced memory usage.

Virtualization is off by default. To turn it on, set property VirtualizingMode to Recycling.

Notification

The attached routed event ItemContainerManager.ContainerVirtualizing is raised by a container prior to being virtualized. If this event is handled (its Handled property set to true) then the container will not be virtualized.

Similarly, a container will raise the attached routed event ItemContainerManager.ContainerRealized after a new container is instantiated and has been connected to its data item and added to the visual tree. The event ItemContainerManager.ContainerRecycled is raised by a container when it is recycled.

Cell Virtualization

By default, when VirtualizingMode = Recycling cells are virtualized as well as rows. Cell virtualization works the same as row virtualization, using recycling as columns are horizontally scrolled into and out of view. However, there might be certain situations where you want node virtualization but don’t want cell virtualization. For this scenario set property SupressCellVirtualization to true.

Selection

Use property SelectionUnit to specify whether rows, cells or both are selected. SelectionUnit is an enumeration of type AdvGridSelectionUnit with the following possible values:

  • None – Selection is disabled.
  • Cell – Cells are selected.
  • Row – Rows are selected.
  • CellOrRowHeader – Cells are selected when clicked. A row is selected when its header is clicked.

To make it so an entire column is selected when the user clicks on the column’s header, set ColumnHeaderClickMode = SelectColumn. This setting also makes it so if the user clicks on top left corner then all columns are selected. When a column is selected, the column definition’s IsSelected property is set to true.

Use the SelectionMode property to select between Single, Multiple and Extended selection modes:

  • Single – Only a single item (row, cell or column) can be selected. When an item is selected the previously selected item is unselected.
  • Multiple – More than one item (row, cell or column) can be selected at a time. Clicking on an item causes it to be selected and added to the current collection of selected rows, cells or columns.
  • Extended – More than one item (row, cell or column) can be selected at a time. In this mode, to select multiple items, either the Control key or the Shift key must be pressed while the item is clicked on. If the Control key is pressed the item’s selection status is toggled and it is either added or removed from the collection of selected rows, cells or columns. If the Shift key is pressed, then an entire range is selected, beginning with the first item in the list of currently selected items and ending with the item which received the click.

The property SelectedItem references the data item of the selected row. When selection mode is multiple or extended, SelectedItems contains the collection of selected rows and SelectedItem will reference the first row selected. The property SelectedCell references the selected cell, or to be more specific, it references an instance of AdvCellSelectionData which has properties RowItem, Definition, and CellContent. When selection mode is multiple or extended, SelectedCells contains the collection of selected cells and SelectedCell will reference the first cell that was selected. Use property SelectedColumns to obtain an enumeration of type ColumnDefinition with all the columns who’s IsSelected property is true.

When the selection changes, the SelectionChanged routed event is raised.

It is important to note that row, cell and column selection are mutually exclusive. That is, when a row or rows are selected, there will not be any cells or columns that are also selected. The same holds true for cells and columns.

Row and Column Pinning

Data Virtualization

Public Interface

AdvGrid Interface

AdvGrid Events:

AutoGeneratingColumn – A routed event raised when a new column is being auto generated. The new column can be customized in a handler for this event.

DeletingSelectedItems – A routed event raised before selected items are deleted as a result of user action. Handle this event to prevent the deletion.

SortByColumnRequested – A routed event raised when the user clicks a column header to sort (ColumnHeaderClickBehavior is SortByColumn.) Handle this event to stop default sorting and provide custom sorting.

SelectionChanged – A routed event raised when the selection changes.

ItemsChanged – A routed event raised when the content of the Items collection changes.

AdvGrid Methods

BeginEdit – Puts the currently active cell in the currently active row into edit mode.

BringIntoView – There are four overrides of BringIntoView which can be used to bring into view a specific row, a specific item, a specific index, and finally one for bringing into view a specific column.

ClearSelection – Clears current selection.

CancelEdit – Clears all pending changes and takes the current row and/or cell out of edit mode. See section on editing for more information.

ClearGroupByColumn – Clears grouping by the specified column.

CommitEdit – Pending changes are committed to underlying data source. See section on editing for more information.

ContainerFromIndex – Get the row at the specified index, with option to create the row if it doesn’t exist (applies when virtualization is enabled.)

ContainerFromItem – Returns the row given an item with optional parameter to specify whether or not to create the row if it does not exist.

DeleteSelected – Deletes the current selection. Before deleting items, the event DeletingSelectedItems is raised and if handled the delete does not happen.

IndexFromContainer – Get the index of the node within the flattened hierarchy of the tree.

IndexFromItem – Get the index of the item within the flattened hierarchy of the tree.

IsItemSelected – Use to determine if a particular item is part of the current selection.

GetActiveRow – Gets the row control which is container for the current ActiveItem.

GroupByColumn – Groups items based on values in the specified column.

MoveDown – Selects and makes active the row below the currently active row.

MoveLeft – Moves one cell to the left of the current cell.

MoveRight – Moves one cell to the right of the current cell.

MoveUp – Selects and makes active the row immediately above the currently active row.

PinItem – Pins the row containing the specified item to either the top or bottom of the viewport.

Remove – Removes (deletes) the specified item from the Items collection. This is the same as calling Items.Remove().

SelectAll – If columns are being displayed, then all columns are selected.

SortByColumn – Causes child nodes to be sorted by the values of a specific column, in a specified direction.

AdvTree properties:

CLR Properties

AllSelected – Will return true if all columns are selected.

Items – Gets a reference to the underlying ItemsCollection. This is a read-only property.

ItemContainerManager – Gets a reference to the object responsible for container (row) creation and virtualization. This is the counterpart to ItemsControl’s ItemContainerGenerator.

LogicalExtent – This is the number of rows in the grid.

FirstVisibleNodeIndex – Gets the index of the first visible node (index is flattened, i.e. inclusive of all nodes regardless of hierarchy level.)

LastVisibleNodeIndex – Gets the index of the last visible node in the tree.

ScrollViewer – Gets a reference to the grid’s ScrollViewer, if there is one.

SelectedColumns – An enumeration of the ColumnDefinitions which are currently selected. Column selection is enabled by setting ColumnHeaderClickBehavior to SelectColumn.

SupressCellVirtualization – When VirtualizationMode is Recycling both nodes and cells are subject to virtualization. Set this property to prevent the virtualization of cells.

Dependency Properties

ActiveItem – This is the data item of the row which currently has keyboard focus. Read-only.

AllowColumnReorder – Specifies whether the user can reorder the columns using drag and drop.

AlternationCount – Performs same function as ItemsControl.AlternationCount. Setting to a value greater than 1 will result in the grid’s rows’ AlternationIndex values alternate between 0 and AlternationCount – 1. This value can be used in a Style trigger to modify properties of the nodes based on their alternation index. An example of this is provided in the sample AdvGridSample.

AutoGenerateColumns – Specifies whether column definitions should be automatically generated from available data when they are not provided.

CanUserAddRow – When true, a placeholder row is added to bottom of the grid. If the user edits a cell in the placeholder row, a new row is created.

CanUserDeleteItem – When true, the user can delete rows by hitting the delete key. Default is false.

ColumnAlternationCount – Alternation count for columns. Works the same as alternation count for rows.

ColumnDefinitions – Defines columns for the Grid. More on columns is provided below.

ColumnHeaderClickBehavior – Determines what happens when a column header is clicked. Possible values are SortByColumn: The rows are sorted by the column’s value. SelectColumn: The column is selected. Custom: No action is taken by the grid. Handle ColumnHeader.Clicked routed event to perform custom action. The column header is highlighted on mouse over and press.) And Nothing: Nothing is done and ColumnHeader.Clicked is not raised.

ColumnHeaderClickMode – Determines whether the click event of a column header is raised on mouse down or mouse up.

ErrorNotification – Applies only when IsByRowEditingEnabled = true. Specifies whether the user is notified of row level errors by a message box, by an Adorner (defined by Validation.ErrorTemplate) or not at all.

ErrorNotificationDialogBoxStyle – This Style is applied to the DialogWindow (DevComponents.WPF.Controls) which is opened to display row level error message.

Filter – A Predicate<object> which is applied to the grid’s Items collection.

FirstRowNumber – Specifies the starting index for the rows, and which are displayed by the row headers.

HighlightSelectedCellColumnHeader – Determines whether the column headers of selected cells are highlighted.

HighlightSelectedCellRowHeader – Determines whether row headers are highlighted cells are selected.

HorizontalGridLineBrush – Brush for horizontal grid lines when ShowHorizontalGridLines is set.

HorizontalGridLineHeight- Height of the horizontal grid line when ShowHorizontalGridLines is set.

HotTrack – When true, the cell with mouse over is highlighted.

IsByRowEditingEnabled – When true, by-row editing is enabled. See section on editing for more. The default value is false.

IsContextMenuEnabled – Determines whether the column header’s built-in context menu should be enabled.

IsDragDropEnabled – When set, the grid is set up to be both source and target of drag/drop. Is the same as setting both DragDrop.IsDropTarget and DragDrop.IsDragSource to true.

IsGrouping – A read-only property which is set to indicate that the items are being grouped.

IsSelectionFocusAware – When true, the selection box which highlights a selected item is grayed when the Grid does not contain the input focus.

ItemsSource – An IEnumerable which serves as source for the items which populate the Items collection. This property is equivalent to ItemsControl.ItemsSource.

ItemContainerStyle – Style for the item containers. Note that containers for AdvGrid are always instances of AdvGridRow.

ItemContainerStyleSelectorStyleSelector for selecting the Style for the container for a particular item.

LockRowHeaderWidth – Specifies whether the user is enabled to resize the width of the row headers. Default is true.

LockRowHeigths – Specifies whether the user is enabled to change row heights. By default will be false unless either virtualization or scroll by item are enabled, in which case LockRowHeight is set to true. The default behavior is overridden when LockRowHeight is explicitly set.

RowKeepsKeyboardFocusOnError – Applies when IsByRowEditingEnabled = true. If there is an error when attempting to commit changes, the user is prevented from navigating away from the row.

RowDetailsShowMode – Determines whether row details are displayed when a toggle button is checked, when the row is selected, always or none (manual.)

RowDetailsTemplate – A DataTemplate which if set both shows how to render the details section and causes the rows to have a details section.

RowHeaderWidth – Specifies the width of the row headers. Default value is NaN, which results in auto-sizing.

ScrollMode – Determines whether scroll-by-item is enabled and, if so, how the last item is positioned. Possible values are Normal, ByItem and ByItemBottomFlush. Default is Normal.

SelectedCell – When SelectionMode is Single and CellSelect is True, this property will identify the currently selected cell. When multiple selection is enabled, SelectedCell will be set to the first cell selected of the collection of selected cells.

SelectedCells – When SelectionMode is Multiple or Extended and CellSelect is True, this property will return an ObservableCollection containing the currently selected cells.

SelectedItem – Will identify the currently selected item when SelectionMode is Single. When multiple selection is enabled, SelectedItem will be set to the first item selected of the collection of selected items.

SelectedItems – When SelectionMode is Extended or Multiple, will return an ObservableCollection containing references to the currently selected items.

SelectionMode – Possible values are Single, Multiple and Extended. More on selection modes is provided below.

SelectionUnit – Determines whether cells, rows or both are selectable by user. This is an enumeration of type AdvGridSelectionUnit with possible values None, Cell, Row and CellOrRowHeader.

ShowColumnGroupingPanel – If true, a panel is shown into which the user can drag column headers for columns to group by.

ShowColumnHeader – Determines whether the column headers are shown.

ShowHorizontalGridLines – Determines whether horizontal grid lines are shown.

ShowRowDetailsRootLine – Applies when RowDetailsTemplate is set.

ShowRowHeaders – Determines whether the row headers are shown.

ShowVerticalGridLines – Determines whether the vertical grid lines are shown.

VerticalGridLineBrush – The Brush used for vertical grid lines.

VirtualizingMode – Sets the virtualization mode for the tree. Possible values are None and Recycling. Default value is None. More about virtualization is provided below.

VisualStyle – 5 built-in visual styles are included with AdvGrid the default, an emulation of Windows Explorer, and the three color schemes of Office 2010: Blue, Silver and Black. Setting this property is the same as setting a value for the VisualStyleManager.VisualStyle attached property on the grid. Note: to ensure consistent visual style through the entire application, set VisualStyleManager.VisualStyle on an element at the top of the visual tree.)

AdvGridRow Interface

AdvGridRow Events

BeforeSelected – A bubbling routed event raised before the value of IsSelected changes from false to true. Setting the event argument’s Handled property to true will cancel the selection.

Connecting – Routed event raised when the row is being connected to its data item and fitted into the visual tree. This event occurs as part of the virtualization/realization process.

Disconnecting – Routed event raised when a row is in the process of formally disconnecting itself from its data item. Will not be raised if virtualization is not enabled.

InitializingNewItemPlaceholder – Routed event raised when the item for the new item placeholder is being created. Will not be raised unless the grid’s CanUserAddItem property is true. Handle this event to set default values for the placeholder item, or to create a new item to serve as placeholder.

IsCellSelectedWithinChanged – Bubbling routed event raised when th value of IsCellSelectedWithin changes.

IsDetailsSectionOpenChanged – Routed event raised when the value of IsDetailsSectionOpen changes.

IsDirtyChanged – Routed event raised when the value of  IsDirty changes.

PinChanged – Routed event raised when the value of Pin changes.

Selected – A bubbling routed event raised when the value of IsSelected changes from false to true.

Unselected – Routed event raised when the value of IsSelected changes to false.

AdvGridRow Methods

BeginEdit – Puts the current cell into edit mode. If IsByRowEditingEnabled = true, then the row is also placed into edit mode.

CancelEdit – Rolls back any pending changes and takes the row and current cell out of edit mode.

CommitEdit – Commits pending changes to underlying data source and optionally takes the row and/or active cell out of edit mode. See section on Editing for more.

GetCell – Use to get an AdvTreeCell contained by the node that corresponds to a specific ColumnDefinition.

GetChildNodes – Use to obtain an enumeration of all of the node’s child nodes. Optionally include all the descendants of the child nodes as well. Option to include nodes which are unrealized.

NavigateLeft – Moves focus to and selects the cell immediately to the left of the currently active cell.

NavigateRight – Moves focus to and selects the cell immediately to right of currently active cell.

NavigateDown – Moves focus to and selects the row below.

NavigateUp – Moves focus to row above.

SortByColumn – Causes the node to sort children by a specified column, in a specified direction.

AdvGridRow Properties

CLR Properties

CellDefinitions – This is the ColumnDefinitionCollection which defines the columns which present the node’s data (not the node’s children.) By default, a node inherits this value from its parent node. If the parent node has a value for ColumnDefinitions, this becomes the child’s CellDefinitions.

Cells – Gets an enumeration of the AdvTreeCell controls which are children of the node. If HasCells is false, this property will return an empty enumerable.

HasCells – Gets whether this node has cells defined.

HeaderControl – Provides access to the control which renders the row’s Header.

IsEditing – Returns true if the node is currently in edit mode.

IsCellEditingWithin – Returns true if a Cell contained by the node is currently in edit mode.

IsConnected – Returns true if the node is currently connected – that is, it is in a valid state for rendering.

Items – An ItemsCollection which contains and manages the child items of the node.

ParentGrid – Gets the parent AdvGrid.

ValidationErrors – If ByRowEditingIsEnabled = true, this ReadOnlyObservableCollection will contain any validation errors that currently exist for the row.

Dependency Properties

AlternationIndex – This is a read only property which is set by the framework when a parent’s AlternationCount is greater than 1. This property can be used in Style trigger to modify appearance of the node.

DetailsTemplate – A data template which defines how to display the details. If set, the row will have a details section, otherwise the row will not have a details section. By default, this value is inherited from the parent grid’s RowDetailsTemplate property.

DetailsToggleButtonStyle – Style for the toggle button which is

ErrorNotification – Applies only when IsByRowEditingEnabled = true. Specifies whether the user is notified of row level errors by a message box, by an Adorner (defined by Validation.ErrorTemplate) or not at all. By default this value is inherited from the parent grid’s property of the same name.

HasError – A read only property which is set when there are validation errors associated with the row.

HeaderBackground – The Brush used to paint the background of the row’s header.

Header – The content displayed by the row’s header.

HeaderPadding – Padding for the header.

HeaderTemplate – A DataTemplate which shows how to render Header.

HorizontalGridLineBrush – Get or set the Brush used for the horizontal grid line. By default, this property is inherited from the parent grid.

HorizontalGridLineHeight – Determines the height of the horizontal grid line. By default, this property is inherited from the parent grid.

IsByRowEditingEnabled – Determines whether the the row is in by-row editing mode. By default, this value is inherited from the parent grid’s property of the same name.

IsCellSelectedWithin – Will be true if one of more cells within the row are selected. Read only.

IsDetailsSectionOpen – Determines whether the details section is open. Ignored if there is no value for DetailsTemplate.

IsDirty – If by-row editing is enabled, this property is set when the user edits a cell and remains set until either the changes have been committed or the edit is cancelled (for example, the user hits the escape key.) See section on editing for more information.

IsEditing – This read-only property is set when the row goes into edit mode. Will never be set unless IsByRowEditingEnabled = true.

IsSelected – Gets or sets whether or not the row is selected. If IsSelectable is false, this property is ignored.

IsSelectable – Determines whether the row can be selected. The default value is true.

KeepKeyboardFocusWhenHasError – If by-row editing is enabled, setting this property make it so the user is prevented from leaving the current row if HasErrors = true. By default, this value is inherited from the parent grid’s RowKeepsKeyboardFocusWhenHasError property.

LockHeight – Determines whether the user can change the row’s height. By default, this value is inherited from the parent grid’s LockRowHeight property.

Pin – Determines whether the row is pinned to the top or bottom of the viewport, or not pinned at all (the default is not pinned.)

ShowHorizontalGridLines – Determines whether the horizontal grid lines are visible.

ValidationRules – Gets or sets a collection of ValidationRule objects used for row-level validation. Ignored if IsByRowEditingEnabled does not equal true. For more information, see section on editing below.

AdvGridCell Interface

AdvGridCell Events

BeforeSelected – A bubbling routed event raised before the value of IsSelected changes from false to true. Setting the event argument’s Handled property to true will cancel the selection.

EditBeginning – A bubbling routed event raised before the cell enters edit mode. Setting the event argument’s Handled property to true will cancel the edit.

EditCommitted – A bubbling routed event raised when changes are committed to the underlying data source.

IsDirtyChanged – A routed event raised when the value of IsDirty changes.

IsEditingChanged – A routed event raised when the value of IsEditing changes.

Selected – A bubbling routed event raised when the value of IsSelected changes from false to true.

Unselected – A bubbling routed event raised when the value of IsSelected changes from true to false.

AdvGridCell Methods

BeginEdit – Manually puts the cell into edit mode.

CancelEdit – Clears pending changes to the cell’s content and takes the cell out of edit mode.

CommitEdit – Commits pending changes with option to exit edit mode. If by-row editing mode is enabled, then the changes are only committed to row level. It is up to the parent row to perform the final commitment of changes to the underlying data source.

AdvGridCell Properties

CLR Properties

IndexInRow – Gets the zero based index of this cell within the row or node.

IsConnected – Gets whether this cell is fully connected to its data source and column definition, and is ready to be displayed in the UI.

IsEditing – Returns true if the cell is currently in edit mode.

Dependency Properties

BeginEditTriggerMode – provides a means for defining what conditions are required for the cell to enter Edit mode. (Only applies when IsEditable is true.) More on node and cell editing is provided below.

CellDefinition – Provides access to the ColumnDefinition instance which defines the cell. This is a read only dependency property.

EditorStyle – Specifies a style which is applied to the embedded EditingContentControl which both displays and edits the cell’s content. Note that the editing control’s style can also be specified in the column definition via property CellEditorStyle. In either case, a value is not required. More on editing below.

EditTemplate – Optionally specifies a ControlTemplate to be applied to the ContentEditingControl which both displays and edits the cells content. More below.

IsDirty – When true, it means the user has made changes to the cell content which have not been committed to the underlying data source.

IsEditable – When true, the cell’s content can be edited in place. See more about editing below.

IsEditing – Set when the cell enters edit mode.

IsHighlighted – Get or set whether the cell should be highlighted. Normally, this value is set when the mouse is over the cell.

IsSelectable – Determines whether the cell can be selected. The default value is true.

IsSelected – Gets or Sets whether the cell is currently selected. If IsSelectable is false, this property is ignored.

Control Templates

AdvGrid Control Template

Here are the default control templates for AdvGrid and AdvGridHeaderCorner. You can use them as a starting place for customizing your own.

<ControlTemplate TargetType="{x:Type dc:AdvGrid}">
    <Border Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
        <Grid Name="MainGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid Height="{Binding ElementName=ColumnsPresenter, Path=HeaderHeight}">
                <dc:AdvGridHeaderCorner x:Name="HeaderCorner" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RowHeaderWidth, Mode=TwoWay}" />
            </Grid>
            <dc:ColumnsPresenter x:Name="ColumnsPresenter" Grid.Column="1" Grid.RowSpan="2"
                                ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColumnDefinitions}"
                                dc:DragDrop.DragAdornerTemplate="{DynamicResource {x:Static dc:AdvGrid.ColumnHeaderDragAdornerTemplateKey}}"
                                dc:DragDrop.DropAdornerTemplate="{DynamicResource {x:Static dc:AdvGrid.ColumnHeaderDropAdornerTemplateKey}}" />
            <ScrollViewer Name="ScrollViewer" Grid.ColumnSpan="2" Grid.Row="1" Padding="0,-1,0,0" Focusable="False" CanContentScroll="True" ClipToBounds="False"
                            IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}">
                <dc:AdvGridPanel x:Name="ItemsHost" Margin="0,1,0,0" />
            </ScrollViewer>
            <TextBlock Name="InitializingMessage" Grid.Row="1" Grid.Column="1" Opacity="0" HorizontalAlignment="Center" VerticalAlignment="Center"
                        Text="{DynamicResource {x:Static dc:AdvGrid.DataInitializingMessageStringKey}}"/>
            <dc:PinnedColumnsSeparator Pin="Left" Grid.Column="1" Grid.RowSpan="2" Visibility="Collapsed" HorizontalAlignment="Left" />
            <dc:PinnedColumnsSeparator Pin="Right" Grid.Column="1" Grid.RowSpan="2" Visibility="Collapsed" HorizontalAlignment="Left" />
        </Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="VirtualizingDataStates">
                <VisualState Name="DataInitialized" />
                <VisualState Name="DataInitializing">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="InitializingMessage" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Border>
    <ControlTemplate.Triggers>
        <Trigger Property="ShowRowHeaders" Value="False">
            <Setter TargetName="HeaderCorner" Property="Visibility" Value="Collapsed" />
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="dc:AdvGridHeaderCorner">
    <Grid Background="{TemplateBinding Background}">
        <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" />
        <Polygon Name="Glyph" Points="10,0 10,10 0,10" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Bottom" Stretch="Uniform" RenderTransformOrigin="0.5,0.5"
                    Fill="{DynamicResource {x:Static dc:AdvGrid.HeaderCornerGlyphBrushKey}}">
            <Polygon.RenderTransform>
                <RotateTransform x:Name="GlyphTransform" Angle="0" />
            </Polygon.RenderTransform>
        </Polygon>
        <Thumb Background="Transparent" Width="4" HorizontalAlignment="Right" VerticalAlignment="Stretch" Cursor="SizeWE" BorderBrush="Transparent"
                Visibility="{Binding RelativeSource={RelativeSource AncestorType=dc:AdvGrid}, Path=LockRowHeaderWidth, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Inverse}">
            <Thumb.Template>
                <ControlTemplate>
                    <Grid Background="Transparent" />
                </ControlTemplate>
            </Thumb.Template>
        </Thumb>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="CheckedStates">
                <VisualState Name="Unchecked" />
                <VisualState Name="Checked">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="GlyphTransform" Storyboard.TargetProperty="Angle" Duration="0" To="180" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Glyph" Storyboard.TargetProperty="HorizontalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static HorizontalAlignment.Left}" />
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Glyph" Storyboard.TargetProperty="VerticalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static VerticalAlignment.Top}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</ControlTemplate>

AdvGridRow Control Template

Here are the default control templates for AdvGridRow and AdvGridRowHeader. You can use them as a starting place for customizing your own.

<ControlTemplate TargetType="dc:AdvGridRow">
    <Grid Background="Transparent">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
 
        <dc:AdvGridRowHeader x:Name="RowHeader" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"
                                Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ParentTable.RowHeaderWidth}" 
                                Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ParentTable.ShowRowHeaders, Converter={StaticResource boolToVisibilityConverter}}" />
 
        <Border Grid.Column="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
        <Border Name="HighlightBorder" Grid.Column="1" Opacity="0" Background="{DynamicResource {x:Static dc:AdvGridRow.HighlightBackgroundKey}}" />
        <Border Name="SelectionBorder" Grid.Column="1" Opacity="0" Background="{DynamicResource {x:Static dc:AdvGridRow.SelectedBackgroundKey}}" />
        <Border Name="SelectedInactiveBorder" Grid.Column="1" Opacity="0" Background="{DynamicResource {x:Static dc:AdvGridRow.SelectedInactiveBackgroundKey}}" />
 
        <Border Name="CellsBorder" Grid.Column="1" BorderBrush="{TemplateBinding HorizontalGridLineBrush}" 
                BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=HorizontalGridLineHeight, Converter={StaticResource doubleToThicknessConverter}, ConverterParameter=Bottom}">
            <dc:AdvCellPanel x:Name="CellPanel" />
        </Border>
        <Rectangle Name="FocusRect" Grid.Column="1" Opacity="0" Stroke="Black" StrokeDashArray="1,2" SnapsToDevicePixels="True" />
 
        <!-- Use a Cell here to ensure height of row when loading matches height of row when loaded. -->
        <dc:AdvGridCell x:Name="LoadingMessage" Visibility="Collapsed" Grid.Column="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" 
                        Margin="20,0,0,0" Content="{DynamicResource {x:Static dc:AdvGridRow.DataLoadingMessageStringKey}}" />
 
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="SelectionStates">
                <VisualState Name="Unselected" />
                <VisualState Name="Selected">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectionBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusRect" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState Name="CellSelectedWithin" />
                <VisualState Name="CellSelectedWithinInactive" />
                <VisualState Name="AllColumnsSelected" />
                <VisualState Name="AllColumnsSelectedInactive" />
                <VisualState Name="SelectedInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedInactiveBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusRect" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="HighlightedStates">
                <VisualState Name="NotHighlighted" />
                <VisualState Name="IsHighlighted">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="HighlightBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusRect" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="FocusStates">
                <VisualState Name="Unfocused" />
                <VisualState Name="Focused">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="FocusRect" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
    <ControlTemplate.Triggers>
        <Trigger Property="ShowHorizontalGridLines" Value="False">
            <Setter TargetName="CellsBorder" Property="BorderThickness" Value="0" />
        </Trigger>
        <Trigger Property="IsDataLoading" Value="True">
            <Setter TargetName="CellPanel" Property="Opacity" Value="0" />
            <Setter TargetName="LoadingMessage" Property="Visibility" Value="Visible" />
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="dc:AdvGridRowHeader">
    <Grid Background="{TemplateBinding Background}">
        <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
            <Grid>
                <Border Name="CellSelectedBorder" Opacity="0" Margin="0,-1,-1,-1" BorderThickness="0,1,1,1" 
                        BorderBrush="{DynamicResource {x:Static dc:AdvGridRow.CellSelectedHeaderBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridRow.CellSelectedHeaderBackgroundKey}}" />
                <Border Name="RowSelectedBorder" Opacity="0" Margin="0,-1,-1,-1" BorderThickness="0,1,1,1" 
                        BorderBrush="{DynamicResource {x:Static dc:AdvGridRow.RowSelectedHeaderBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridRow.RowSelectedHeaderBackgroundKey}}" />
                <Border Name="SelectedInactiveBorder" Opacity="0" Margin="0,-1,-1,-1" BorderThickness="0,1,1,1" 
                        BorderBrush="{DynamicResource {x:Static dc:AdvGridRow.SelectedInactiveHeaderBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridRow.SelectedInactiveHeaderBackgroundKey}}" />
                <Border Name="HighlightBorder"  Opacity="0" Margin="0,-1,-1,-1" BorderThickness="0,1,1,1" 
                        BorderBrush="{DynamicResource {x:Static dc:AdvGridRow.HighlightHeaderBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridRow.HighlightHeaderBackgroundKey}}" />
                <ContentPresenter Name="Presenter" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                <Path Name="FocusGlyph" Opacity="0" Style="{DynamicResource {x:Static dc:AdvGridRow.HeaderSelectedGlyphStyleKey}}" />
            </Grid>
        </Border>
        <Thumb HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="3" Cursor="SizeNS" Template="{StaticResource RowHeaderThumbTemplate}"
                Visibility="{Binding RelativeSource={RelativeSource AncestorType=dc:AdvGridRow}, Path=LockHeight, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Inverse}" />
        <Thumb VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="3" Cursor="SizeWE" Template="{StaticResource RowHeaderThumbTemplate}"
                Visibility="{Binding RelativeSource={RelativeSource AncestorType=dc:AdvGrid}, Path=LockRowHeaderWidth, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Inverse}" />
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="CommonStates">
                <VisualState Name="Normal" />
                <VisualState Name="Disabled" />
                <VisualState Name="Highlighted">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="HighlightBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="FocusStates">
                <VisualState Name="RowUnfocused" />
                <VisualState Name="RowFocused">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="FocusGlyph" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="SelectionStates">
                <VisualState Name="Unselected" />
                <VisualState Name="Selected">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="RowSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="CellSelectedWithin">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="CellSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="AllColumnsSelected">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="RowSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="SelectedInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedInactiveBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="CellSelectedWithinInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedInactiveBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="AllColumnsSelectedInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedInactiveBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</ControlTemplate>

AdvGridCell Control Template

Here is the default control template for AdvGridCell. You can use it as a starting place for customizing your own.

<ControlTemplate TargetType="dc:AdvGridCell">
    <Grid Name="MainGrid" Background="Transparent">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
        <Border Name="SelectedBorder" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}" 
                BorderBrush="{DynamicResource {x:Static dc:AdvGridCell.IsSelectedBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridCell.IsSelectedBackgroundKey}}" />
        <Border Name="InactiveSelectedBorder" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}" 
                BorderBrush="{DynamicResource {x:Static dc:AdvGridCell.SelectedInactiveBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridCell.SelectedInactiveBackgroundKey}}" />
        <Border Name="HighlightBorder" Opacity="0" BorderThickness="{TemplateBinding BorderThickness}" 
                BorderBrush="{DynamicResource {x:Static dc:AdvGridCell.IsHighlightedBorderBrushKey}}" Background="{DynamicResource {x:Static dc:AdvGridCell.IsHighlightedBackgroundKey}}" />
        <Rectangle Name="GridLine" Grid.Column="1" VerticalAlignment="Stretch"
                    Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CellDefinition.ParentCollection.ShowGridLines, Converter={StaticResource boolToVisibilityConverter}}"
                    Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CellDefinition.GridLineBrush}" 
                    Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CellDefinition.GridLineWidth}" />
        <dc:EditingContentControl x:Name="Editor" Margin="-1" Style="{TemplateBinding EditorStyle}" Validation.ErrorTemplate="{TemplateBinding Validation.ErrorTemplate}"
                                    Padding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={StaticResource additionConverter}, ConverterParameter=1}"
                                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    EditorSettings="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CellDefinition.EditorSettings}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Mode=TwoWay, UpdateSourceTrigger=Explicit}" />
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="CommonStates">
                <VisualState Name="Normal" />
                <VisualState Name="Disabled" />
                <VisualState Name="Highlighted">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="HighlightBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.03" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="SelectionStates">
                <VisualState Name="Unselected" />
                <VisualState Name="Selected">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.03" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="SelectedByColumn">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.03" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="SelectedInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="InactiveSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="00:00:00.03" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>                            
        </VisualStateManager.VisualStateGroups>
    </Grid>
</ControlTemplate>

ColumnsPresenter Control Template

Here are the default ControlTemplates for ColumnsPresenter and ColumnPresenter. You can use them as starting place for customizing your own templates for these controls.

<ControlTemplate TargetType="{x:Type ctrls:ColumnsPresenter}">
    <Grid Name="MainGrid">
        <Grid.ContextMenu>
            <ContextMenu ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColumnDefinitions}" 
                            ItemContainerStyle="{DynamicResource {x:Static ctrls:ColumnsPresenter.ContextMenuItemStyleKey}}" />
        </Grid.ContextMenu>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ContentPresenter Name="Label" Content="{TemplateBinding Label}" ContentTemplate="{TemplateBinding LabelTemplate}" />
        <Border Grid.Row="1" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
            <Grid>
                <Rectangle VerticalAlignment="Top" Height="{TemplateBinding HeaderHeight}" Fill="{TemplateBinding HeaderBackground}" />
                <ItemsPresenter />
                <Border VerticalAlignment="Top" Height="{TemplateBinding HeaderHeight}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding HeaderBorderThickness}" />
            </Grid>
        </Border>
    </Grid>
    <ControlTemplate.Triggers>
        <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColumnDefinitions.IsContextMenuEnabled}" Value="False">
            <Setter TargetName="MainGrid" Property="Grid.ContextMenu" Value="{x:Null}" />
        </DataTrigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="ctrls:ColumnPresenter">
    <Grid Background="Transparent" SnapsToDevicePixels="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <ctrls:ColumnHeader x:Name="Header" Visibility="{Binding ShowHeader, Converter={StaticResource boolToVisibilityConverter}}" />
        <Thumb Name="ResizeThumb" Width="6" HorizontalAlignment="Right" Cursor="SizeWE" 
                Visibility="{Binding AllowColumnResize, Converter={StaticResource boolToVisibilityConverter}}">
            <Thumb.Template>
                <ControlTemplate>
                    <Grid Background="Transparent" />
                </ControlTemplate>
            </Thumb.Template>
        </Thumb>
        <Border Name="ColumnBorder" Grid.Row="1" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" />
        <Rectangle Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Top"
                    Height="{Binding RelativeSource={RelativeSource AncestorType=ctrls:AdvTabularControl}, Path=Padding, Converter={StaticResource thicknessToDoubleConverter}, ConverterParameter=Top}" 
                    Fill="{Binding GridLineBrush}" Width="{Binding GridLineWidth}" />
    </Grid>
    <ControlTemplate.Triggers>
        <Trigger Property="Pin" Value="Right">
            <Setter TargetName="ResizeThumb" Property="HorizontalAlignment" Value="Left" />
            <Setter TargetName="ResizeThumb" Property="Margin" Value="-6,0,0,0" />
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="ctrls:ColumnHeader">
    <ControlTemplate.Resources>
    </ControlTemplate.Resources>
    <Grid Background="Transparent">
        <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" />
        <Border Name="CellSelectedBorder" Margin="-1,0,0,0" Opacity="0" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource {x:Static ctrls:ColumnPresenter.CellSelectedHeaderBorderBrushKey}}"
                Background="{DynamicResource {x:Static ctrls:ColumnPresenter.CellSelectedHeaderBackgroundKey}}" />
        <Border Name="ColumnSelectedBorder" Margin="-1,0,0,0" Opacity="0" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource {x:Static ctrls:ColumnPresenter.ColumnSelectedHeaderBorderBrushKey}}"
                Background="{DynamicResource {x:Static ctrls:ColumnPresenter.ColumnSelectedHeaderBackgroundKey}}" />
        <Border Name="SelectedInactiveBorder" Margin="-1,0,0,0" Opacity="0" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource {x:Static ctrls:ColumnPresenter.SelectedInactiveHeaderBorderBrushKey}}"
                Background="{DynamicResource {x:Static ctrls:ColumnPresenter.SelectedInactiveHeaderBackgroundKey}}" />
        <Border Name="PressedBorder" Margin="-1,0,0,0" Opacity="0" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource {x:Static ctrls:ColumnPresenter.HeaderHighlightBorderBrushKey}}"
                Background="{DynamicResource {x:Static ctrls:ColumnPresenter.HeaderPressedBackgroundKey}}" />
        <Border Name="HighlightBorder" Margin="-1,0,0,0" Opacity="0" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource {x:Static ctrls:ColumnPresenter.HeaderHighlightBorderBrushKey}}"
                Background="{DynamicResource {x:Static ctrls:ColumnPresenter.HeaderHighlightBackgroundKey}}" />
        <ContentPresenter Name="Presenter" Margin="{TemplateBinding Padding}" 
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
        <Control Name="SortGlyph" Grid.Column="1" Style="{DynamicResource {x:Static ctrls:ColumnPresenter.ColumnSortGlyphStyleKey}}" />
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup Name="CommonStates">
                <VisualState Name="Normal" />
                <VisualState Name="Disabled" />
                <VisualState Name="Highlighted">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="HighlightBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="Pressed">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="PressedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup Name="SelectionStates">
                <VisualState Name="Unselected" />
                <VisualState Name="ColumnSelected">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="ColumnSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="CellSelectedWithin">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="CellSelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
                <VisualState Name="SelectedInactive">
                    <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="SelectedInactiveBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</ControlTemplate>

The following is the Style applied to the ContextMenu that is created by default for ColumnsPresenter when IsContextMenuActive = true.

<Style x:Key="{x:Static ctrls:ColumnsPresenter.ContextMenuItemStyleKey}" TargetType="MenuItem">
    <Style.Resources>
        <ctrls:VisibilityToBooleanConverter x:Key="visibilityToBoolConverter" />
    </Style.Resources>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static ctrls:MenuResources.MenuItemForegroundKey}}" />
    <Setter Property="Padding" Value="{DynamicResource {x:Static ctrls:MenuResources.MenuItemPaddingKey}}" />
    <Setter Property="IsCheckable" Value="True" />
    <Setter Property="IsChecked" Value="{Binding Visibility, Converter={StaticResource visibilityToBoolConverter}, Mode=TwoWay}" />
    <Setter Property="Header" Value="{Binding Header}" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsLocked}" Value="True">
            <Setter Property="Visibility" Value="Collapsed" />
        </DataTrigger>
    </Style.Triggers>
</Style>

Related posts:

  1. WPF Color Control Quick Start Guide
  2. Brush Control Quick Start Guide
  3. WPF AdvTree Quick Start Guide
  4. WPF EnumPicker
  5. Rating Control for WPF Quick Start Guide