ShellContextMenu Class |
MenuItems that are specified beneath the ShellContxtMenu will be added as custom items to the ShellContextMenu. ShowShellContextMenuOnTop controls the order of custom vs. shellitems in the menu.
Using the SystemStyle property, you can configure how the context menu is hosted. If true, the menu will be presented as Win32 context menu, the custom menu items will be transformed. If false, then menu is transformed to a WPF menu.Namespace: Jam.Shell.WPF.Controls
The ShellContextMenu type exposes the following members.
Name | Description | |
---|---|---|
ShellContextMenu | Default constructor. |
Name | Description | |
---|---|---|
ShellItem | Gets or sets the ItemIdList for which the context menu is invoked. | |
ShellItems | Gets or sets a collection of ItemIdLists defining the objects the shell context menu will be displayed for. | |
ShowShellContextMenuOnTop |
Determines the order of shell menu items and custom menu items.
| |
SystemStyle | Gets or sets a value indicating whether to show the menu as Win32 menu or as native WPF menu. | |
Version |
The current version of ShellBrowser Components WPF.
|
Name | Description | |
---|---|---|
OnAfterCommandExecute | Fires the AfterCommandExecute event. | |
OnBeforeCommandExecute | Fires the BeforeCommandExecute event. | |
OnOpened |
Called when the Opened
event occurs. Opens the ShellContextMenu instead.
(Overrides ContextMenuOnOpened(RoutedEventArgs).) | |
OnPropertyChanged |
Invoked whenever the effective value of any dependency property on this
FrameworkElement
has been updated. The specific dependency property that changed is reported in the arguments
parameter. Overrides
OnPropertyChanged(DependencyPropertyChangedEventArgs)
.
(Overrides FrameworkElementOnPropertyChanged(DependencyPropertyChangedEventArgs).) | |
OnRenameItemSelected |
Fires the RenameItemSelected event
|
Name | Description | |
---|---|---|
AfterCommandExecute |
This event is fired after a command that was selected from the context menu or passed to
ExecuteCommand(ShellContextMenuCommand) is processed.
| |
BeforeCommandExecute |
This event is fired before a command that was selected from the context menu or passed to
ExecuteCommand(ShellContextMenuCommand) is processed.
| |
RenameItemSelected |
This event is fired when the context menu option "Rename" is selected from the context menu or passed to ExecuteCommand(ShellContextMenuCommand).
|
Name | Description | |
---|---|---|
ShellItemProperty |
The DependencyProperty for Location.
| |
ShellItemsProperty |
Using a DependencyProperty as the backing store for Selection. This enables animation,
styling, binding, etc...
|
<TextBox Name="PathEdit" Text="{Binding SelectedFile, Mode=TwoWay}"> <TextBox.ContextMenu> <!-- Shows the shell context menu for file path contained in the parent TextBox --> <shlbr:ShellContextMenu ShellItem="{Binding PlacementTarget.Text, RelativeSource={RelativeSource Self}}"/> </TextBox.ContextMenu> </TextBox>
<ListView Name="listView1" ItemsSource="{Binding CurrentDirectory}"> <ListView.Resources> <DataTemplate DataType="{x:Type shellbrowser:ItemIdList}"> <StackPanel Orientation="Horizontal"> <shlbr:ShellThumbnail ImageSize="SmallIcons" Location="{Binding}"/> <TextBlock Padding="10, 0, 0, 0" Text="{Binding Path=Caption}"/> </StackPanel> </DataTemplate> </ListView.Resources> <ListView.ContextMenu> <!-- Shows the shell context menu for the ItemIdLists contained in SelectedItemIdLists - a JamShellItemCollection held in the viewmodel and updated to represent the ListView's SelectedItems property. --> <shlbr:ShellContextMenu ShellItems="{Binding SelectedItemIdLists}"/> </ListView.ContextMenu> </ListView>
<ListView Name="listView3" ItemsSource="{Binding CurrentDirectory}"> <ListView.Resources> <DataTemplate DataType="{x:Type shellbrowser:ItemIdList}"> <StackPanel Orientation="Horizontal"> <shlbr:ShellThumbnail ImageSize="SmallIcons" Location="{Binding}"/> <TextBlock Padding="10, 0, 0, 0" Text="{Binding Path=Caption}"/> </StackPanel> </DataTemplate> </ListView.Resources> <ListView.ContextMenu> <!-- Shows the shell context menu for the ItemIdLists available through the SelectedItems property of the ListView. --> <shlbr:ShellContextMenu ShellItems="{Binding ElementName=listView2, Path=SelectedItems}"> <!-- 2 custom menu items are added to the top, on is handled via click eventhandler, the other via Command.:--> <MenuItem Header="Open cmd here" Command="{Binding OpenCmdPrompt}" CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" /> <MenuItem Header="Sum file sizes" Click="MenuItem_Click"/> </shlbr:ShellContextMenu> </ListView.ContextMenu> </ListView>
Using the BeforeCommandExecute and AfterCommandExecute events, you can intercept before or after shell context menu commands the user has chosen are executed, as can be seen in the following snippets.
private void ShellMenu1_AfterCommandExecute(object sender, ShellCommandEventArgs e) { //write a debug message for failing context menu calls. if (!e.CommandSucceeded) System.Diagnostics.Debug.WriteLine("Context menu {0} failed: {1}", e.Verb, e.Error); } private void ShellMenu1_BeforeCommandExecute(object sender, BeforeShellCommandEventArgs e) { //do not execute the "Open" action, if it affects more than one element. e.Cancel = e.Verb == ShellCommand.Open && (e.Items.Count > 1); }