This is a migrated thread and some comments may be shown as answers.

Get the current line on which we have made a right click

2 Answers 52 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Julien
Top achievements
Rank 1
Julien asked on 25 Aug 2010, 02:51 PM
Hi!

I've a  Tree, that has a RadContextMenu(Telerik's version of Context Menu). On every ItemMenu, I've an action.

I need to know, on which element of my Tree i've right clicked. How can I do this?

I tried to use the "SelectItem", but it seems the tree doesn't select on right click.

Thank you!

<Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.Resources>
<HierarchicalDataTemplate x:Key="NodeTemplate" ItemsSource="{Binding SubNodes}">
                                <StackPanel  Orientation="Horizontal">
                                        <TextBlock Text="{Binding Name}"/>
                                </StackPanel>                               
                            </HierarchicalDataTemplate>
                        </Grid.Resources>
<telerik:RadTreeView Name="uxRadTreeView" ItemsSource="{Binding RootFolder.SubNodes}" ItemTemplate="{StaticResource NodeTemplate}" AllowDrop="False" IsDragDropEnabled="True" DragEnded="uxRadTreeView_DragEnded" MouseRightButtonUp="uxRadTreeView_MouseRightButtonUp">
                            <telerik:RadContextMenu.ContextMenu>
                                <telerik:RadContextMenu IsEnabled="{Binding MainTree.CurrentItem.IsFolder, Mode=OneWay}"  >
                                    <telerik:RadMenuItem Header="Create new folder" Icon="/GuiResources;component/ActionsIcons/newFolder.png" Click="NewFolder" />
                                    <telerik:RadMenuItem Header="Create new file"  Icon="/GuiResources;component/ActionsIcons/newFile.png" Click="NewFile"/>
                                    <telerik:RadMenuItem Header="Add a new version of this file" Icon="/GuiResources;component/ActionsIcons/newFileVersion.png" Click="NewFileVersion"/>
                                    <telerik:RadMenuItem Header="Delete" Icon="/GuiResources;component/ActionsIcons/delete.png" Click="Delete"/>
                                </telerik:RadContextMenu>
                            </telerik:RadContextMenu.ContextMenu>
                        </telerik:RadTreeView>
                    </Grid>

2 Answers, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 26 Aug 2010, 09:07 AM
Hello Julien,

You can check the online example representing exactly the same behavior you are trying to achieve. What you need is to use the ContextMenu.GetClickedElement<RadTreeViewItem>();

Kind regards,
Kaloyan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 26 Aug 2010, 09:33 AM
Great it works for me like a charm. Thank you so much!
Tags
ContextMenu
Asked by
Julien
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Julien
Top achievements
Rank 1
Share this question
or