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

3 posts, 1 answers
  1. Julien
    Julien avatar
    236 posts
    Member since:
    Jul 2010

    Posted 25 Aug 2010 Link to this post

    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. Answer
    Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 26 Aug 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Julien
    Julien avatar
    236 posts
    Member since:
    Jul 2010

    Posted 26 Aug 2010 Link to this post

    Great it works for me like a charm. Thank you so much!
Back to Top