Hi All,
Edit: The title should state that the issue is with ListView items and not ListBox items. Cannot change it now - sorry about the confusion.
I am trying to put a context menu on items in a ListView when that ListView is contained within a RadPanelBarItem that has a context menu. I hope the code example below illustrates what I am trying to do. If I don't add the following then the list items show the expected menu.
When I add it (as shown in the snippet below) then I always get the context menu associated with the RadPanelBarItem when I right click on the ListView elements rather than the context menu specified for the ListView.ItemContainerStyle.
Any help would be appreciated. My code snippet is below.
x
Edit: The title should state that the issue is with ListView items and not ListBox items. Cannot change it now - sorry about the confusion.
I am trying to put a context menu on items in a ListView when that ListView is contained within a RadPanelBarItem that has a context menu. I hope the code example below illustrates what I am trying to do. If I don't add the following then the list items show the expected menu.
<telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="_macroActionContextMenu" /> </telerik:RadContextMenu.ContextMenu>When I add it (as shown in the snippet below) then I always get the context menu associated with the RadPanelBarItem when I right click on the ListView elements rather than the context menu specified for the ListView.ItemContainerStyle.
Any help would be appreciated. My code snippet is below.
<telerik:RadPanelBarItem Name="_rpbiMacros" Header="Macros" IsDropAllowed="False" Foreground="#FF4D4D4D" BorderBrush="#FFBCB596" > <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu x:Name="_macroActionContextMenu" /> </telerik:RadContextMenu.ContextMenu> <!--Constrain the size of the wrap panel so it can do its thing--> <Grid Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadPanelBar}}, Path=ActualWidth, Converter={StaticResource mathConverter}, ConverterParameter=@VALUE-12;0}"> <!-- View as icons --> <WrapPanel Name="_wrpMacroActions" Visibility="{Binding ViewMacroActionListAsIcons, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Visibility.Collapsed}"> <ItemsControl ItemsSource="{Binding MacroActionViewModelList}" >... omitted for clarity </ItemsControl> </WrapPanel> <!-- View as list --> <ListView x:Name="_lviewMacroActions" ItemsSource="{Binding MacroActionViewModelList}" ButtonBase.Click="OnClick_ListViewHeader" Visibility="{Binding ViewMacroActionListAsIcons, Converter={StaticResource invertBoolToVisibilityConverter}, ConverterParameter=Visibility.Collapsed}" > <ListView.Resources> <ContextMenu x:Key="itemContextMenu"> <MenuItem Header="Open" Click="OnClick_EditMacroAction"> </MenuItem> <MenuItem Header="Delete" Click="OnClick_DeleteMacroAction" > <MenuItem.Icon> <ContentControl Template="{StaticResource _rscDeleteImage}" /> </MenuItem.Icon> </MenuItem> </ContextMenu> </ListView.Resources> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Setter Property="telerik:RadContextMenu.ContextMenu" Value="{StaticResource itemContextMenu}" /> <EventSetter Event="MouseDoubleClick" Handler="OnDoubleClick_MacroAction" /> </Style> </ListView.ItemContainerStyle> <ListView.View> <GridView> <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Model.MacroName}"/> <GridViewColumn Header="Description" DisplayMemberBinding="{Binding Model.MacroDescription}" /> </GridView> </ListView.View> </ListView> </Grid> </telerik:RadPanelBarItem>x