In This Article

ShellListView Control

The ShellListView control shows the contents of a selected folder using column-based property display, similar to what you see in the right side of Windows Explorer.

Screenshot

Getting Started

First, add references to the ActiproSoftware.Shell.Wpf.dll, ActiproSoftware.Grids.Wpf.dll, ActiproSoftware.Shared.Wpf.dll assemblies. All three assemblies are required for the Shell product. They should have been installed in the GAC during the control installation process. However, they also will be located in the appropriate Program Files folders. See the product's Readme for details on those locations.

This sample code shows how a ShellListView control pointing to a default root shell folder can be added to any XAML:

xmlns:shell="http://schemas.actiprosoftware.com/winfx/xaml/shell"
...
<shell:ShellListView RootShellFolderParsingName="C:\" />

Default Shell Service

The DefaultShellService property is set to an instance of WindowsShellService by default. This allows the control to support Windows shell interaction out of the box.

Important

Please see the Memory Management topic for notes on handling shell service changes, since they sometimes use unmanaged resources.

Root Shell Folder

A root shell folder must be set on the control so that it can display that root folder's hierarchy. The root shell folder may be set via three different properties:

Important

Please see the Memory Management topic for notes on handling root shell folder changes, since they sometimes use unmanaged resources.

Display Options

There are several display option properties that affect features and functionality:

  • CanIncludeFiles - Whether files should be displayed. The default value is true.
  • CanIncludeFolders - Whether folders should be displayed. The default value is true.
  • CanIncludeLinks - Whether links should be displayed. The default value is true.
  • IsRootItemVisible - Whether the root item is visible. The default value is false, and this inherited value should not be changed for the ShellListView control.

Selection

Since this control inherits TreeListBox, it also inherits that control's SelectedItem, SelectedItems, and SelectionMode properties, and the SelectionChanged event. The "items" in this shell UI control are of type ShellObjectViewModel, as described in the Grids Foundation and Item Adapter topic, so the SelectedItem and SelectedItems properties will return a value of that type. The SelectionMode property determines whether single or multi-selection modes are enabled. For ShellListView, this is generally left as an extended multi-selection.

Layout Modes

The ShellListView control is in Details layout mode by default, which renders items in a vertical list with multiple columns of data.

The LayoutMode property can be set to another ShellListViewLayoutMode enumeration value to change to an alternate layout mode, such as the LargeIcons layout mode pictured here:

Screenshot

Available layout modes include:

  • Details - A detailed vertical list mode with multiple column display.
  • List - A vertical list mode that renders a small icon and name.
  • SmallIcons - A horizontal list mode that renders a small icon and name.
  • MediumIcons - A horizontal list mode that renders a medium icon and name.
  • LargeIcons - A horizontal list mode that renders a large icon and name.
  • ExtraLargeIcons - A horizontal list mode that renders an extra-large icon and name.

The MediumIcons, LargeIcons, and ExtraLargeIcons layout modes can optionally show thumbnail images in place of icons when they are available. Thumbnail images provide previews of the shell object's content. This functionality is enabled by setting the CanUseThumbnails property to true, which is the default.

Item Templates

The control uses multiple DataTemplate-based properties to determine how to render content in various layout modes. The proper DataTemplate is selected by the ShellListViewItemTemplateSelector instance that is set by default to the ItemTemplateSelector property.

The DataTemplate properties for each layout mode include:

This is a sample DataTemplate set to the DetailsLayoutModeItemTemplate property:

<DataTemplate>
	<shared:PixelSnapper VerticalRoundMode="RoundToEven">
		<Grid Margin="2,1" Background="Transparent" ToolTip="{Binding ToolTip, Mode=OneWay, IsAsync=True}">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>

			<Image Width="16" Height="16" VerticalAlignment="Center" Source="{Binding SmallIcon, Mode=OneWay}" />
			<Image Width="16" Height="16" VerticalAlignment="Center" Source="{Binding SmallIconOverlay, Mode=OneWay}" />
			<shell:ShellEditableContentControl Grid.Column="1" Margin="2,0,0,0" Content="{Binding Name, Mode=TwoWay}" IsEditing="{Binding IsEditing, Mode=TwoWay}" />
		</Grid>
	</shared:PixelSnapper>
</DataTemplate>

The CanNavigateIntoChildFolders property determines whether double-clicking or pressing Enter on an item causes the control's RootShellFolder to be set to the IShellObject whose view-model item triggered the event. The default value is true.

When the ShellListView.RootShellFolder is two-way bound to a ShellTreeListBox.SelectedShellObject property, a navigation change into a folder will also update the selection in the paired ShellTreeListBox control.

Context Menus

The IsDefaultItemContextMenuEnabled property determines whether the default context menu is enabled for shell objects. The default value is true.

The context menus themselves are provided by the ShellObjectItemAdapter. Please see the Grids Foundation and Item Adapter topic for more information on how to customize the context menus for both the selection view-models and for the background of the control.

Inline Renaming

The control supports inline renaming if the IsRenamingEnabled property is true, which is the default value. Note that the shell object to be renamed must also support renaming via the IShellObject.CanRename property.

Renaming begins when single clicking on the shell object name, or by selecting an item and pressing F2.

Column Header Template

The control uses this default DataTemplate in its ColumnHeaderTemplate property:

<DataTemplate>
	<TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
</DataTemplate>

Change the ColumnHeaderTemplate property to use an alternate DataTemplate.

Properties

The ShellListView control can show one or more columns, where each column represents an IShellProperty.

The Shell Services topic covers how a shell service provides the shell properties for the RootShellFolder. It also covers how the property values, that are displayed in the list view's cells, are provided. Both of these operations can be customized.

Sorting

Each IShellProperty defines a default sort order. When clicking on a ShellListView column header, the clicked column will be sorted by its default sort order. Clicking on the same column will reverse the sort order.

The Shell Services topic talks about how property value comparisons can be made to properly sort shell objects by a shell property.

The sort order will be reset to its default whenever a new root folder is set. This behavior can be prevented by setting the CanResetSortOnRootShellFolderChange property to false.

The SortShellPropertyKey property gets or sets the IShellProperty.Key of the column to sort. The Name column is sorted by default when this property is a null value. The TreeListViewColumn.Header property for each column is an instance of an IShellProperty, and can be used when locating a key to use for sorting a specific column.

The SortDirection property returns a ColumnSortDirection that determines whether the column sorting is in ascending or descending order.