Hi Telerik,
I have the xaml below, which gives me a control that responds beautifully to mouse-right-clicks and displays the context menu. The special key on my keyboard for context menu is ignored, however. Any clues as to what I am doing wrong?
Thanks,
Anders, Denmark
<UserControl x:Class="Rap1D.Rap1D_WPF.Controls.Navigator.NavigatorControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WorkspaceExplorer="clr-namespace:Rap1D.ViewModelLayer.Implementations.Commands.WorkspaceExplorer;assembly=Rap1D.ViewModelLayer.Implementations"
xmlns:TreeViewItems="clr-namespace:Rap1D.ViewModelLayer.Implementations.TreeViewItems;assembly=Rap1D.ViewModelLayer.Implementations"
xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation">
<DockPanel>
<TreeView ItemsSource="{Binding Path=Children, NotifyOnSourceUpdated=True}" Name="treeview">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="WorkspaceExplorer:MouseDoubleClickBehavior.MouseDoubleClick" Value="{Binding ActivateItemCommand}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources>
<HierarchicalDataTemplate x:Key="MenuItemTemplate"
ItemsSource="{Binding ContextMenuItems}">
<TextBlock Text="{Binding Text}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProjectViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Project.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProductViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Product.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProductDesignViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\ProductDesign.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type TreeViewItems:ProductComponentViewModel}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Component.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</TreeView.Resources>
<Controls:RadContextMenu.ContextMenu>
<Controls:RadContextMenu x:Name="radContextMenu"
ItemTemplate="{StaticResource MenuItemTemplate}">
<Controls:RadMenuItem Header="C_ut"
Command="{Binding CutCommand}" />
<Controls:RadMenuItem Header="Copy"
Command="{Binding CopyCommand}" />
<Controls:RadMenuItem Header="Paste"
Command="{Binding PasteCommand}" />
<Controls:RadMenuItem Header="Delete"
Command="{Binding DeleteCommand}" />
<Controls:RadMenuItem Header="_Editor"
Command="{Binding ShowEditorCommand}" />
</Controls:RadContextMenu>
</Controls:RadContextMenu.ContextMenu>
</TreeView>
</DockPanel>
</UserControl>
I have the xaml below, which gives me a control that responds beautifully to mouse-right-clicks and displays the context menu. The special key on my keyboard for context menu is ignored, however. Any clues as to what I am doing wrong?
Thanks,
Anders, Denmark
<UserControl x:Class="Rap1D.Rap1D_WPF.Controls.Navigator.NavigatorControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WorkspaceExplorer="clr-namespace:Rap1D.ViewModelLayer.Implementations.Commands.WorkspaceExplorer;assembly=Rap1D.ViewModelLayer.Implementations"
xmlns:TreeViewItems="clr-namespace:Rap1D.ViewModelLayer.Implementations.TreeViewItems;assembly=Rap1D.ViewModelLayer.Implementations"
xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation">
<DockPanel>
<TreeView ItemsSource="{Binding Path=Children, NotifyOnSourceUpdated=True}" Name="treeview">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="WorkspaceExplorer:MouseDoubleClickBehavior.MouseDoubleClick" Value="{Binding ActivateItemCommand}" />
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="FontWeight" Value="Normal" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources>
<HierarchicalDataTemplate x:Key="MenuItemTemplate"
ItemsSource="{Binding ContextMenuItems}">
<TextBlock Text="{Binding Text}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProjectViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Project.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProductViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Product.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type TreeViewItems:ProductDesignViewModel}" ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\ProductDesign.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type TreeViewItems:ProductComponentViewModel}">
<StackPanel Orientation="Horizontal">
<Image Width="16" Height="16" Margin="3,0" Source="Images\Component.png" />
<TextBlock Text="{Binding DisplayName}" />
</StackPanel>
</DataTemplate>
</TreeView.Resources>
<Controls:RadContextMenu.ContextMenu>
<Controls:RadContextMenu x:Name="radContextMenu"
ItemTemplate="{StaticResource MenuItemTemplate}">
<Controls:RadMenuItem Header="C_ut"
Command="{Binding CutCommand}" />
<Controls:RadMenuItem Header="Copy"
Command="{Binding CopyCommand}" />
<Controls:RadMenuItem Header="Paste"
Command="{Binding PasteCommand}" />
<Controls:RadMenuItem Header="Delete"
Command="{Binding DeleteCommand}" />
<Controls:RadMenuItem Header="_Editor"
Command="{Binding ShowEditorCommand}" />
</Controls:RadContextMenu>
</Controls:RadContextMenu.ContextMenu>
</TreeView>
</DockPanel>
</UserControl>