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

Context menu the easy way

1 Answer 93 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
JDT
Top achievements
Rank 1
JDT asked on 16 May 2010, 07:25 AM
I think telerik documentation tends to over complicate things. For example the help section for adding context menu to a radtreeview is insane. Binding this, binding that...really confused me. Luckily the demo code shows us an easy way. Don't forget to add the below attribute if you are using the <object> tag on your website, where the silverlight control is referenced.

<param name="windowless" value="true" />
<telerikNavigation:RadTreeView x:Name="RadTreeView1" Margin="10"
            <telerikNavigation:RadContextMenu.ContextMenu> 
                <telerikNavigation:RadContextMenu x:Name="contextMenu"
                    <telerikNavigation:RadMenuItem Header="Add New Item" /> 
                    <telerikNavigation:RadMenuItem Header="Remove Item" /> 
                    <telerikNavigation:RadMenuItem Header="Disable" /> 
                    <telerikNavigation:RadMenuItem Header="Enable" /> 
                </telerikNavigation:RadContextMenu> 
            </telerikNavigation:RadContextMenu.ContextMenu> 
            <telerikNavigation:RadTreeViewItem Header="Personal Folders" 
                    DefaultImageSrc="/TreeView/Images/Outlook/1PersonalFolders.png" 
                    IsExpanded="True"
                <telerikNavigation:RadTreeViewItem Header="Deleted Items(6)" 
                        DefaultImageSrc="/TreeView/Images/Outlook/2DeletedItems.png" /> 
                <telerikNavigation:RadTreeViewItem Header="Drafts" 
                        DefaultImageSrc="/TreeView/Images/Outlook/3Drafts.png" /> 
                <telerikNavigation:RadTreeViewItem Header="Inbox(14)" 
                        DefaultImageSrc="/TreeView/Images/Outlook/4Inbox.png" IsExpanded="True"
                    <telerikNavigation:RadTreeViewItem Header="Folders" 
                            DefaultImageSrc="/TreeView/Images/Outlook/folder.png" /> 
                </telerikNavigation:RadTreeViewItem> 
                <telerikNavigation:RadTreeViewItem Header="Junk E-mails" 
                        DefaultImageSrc="/TreeView/Images/Outlook/junk.png" /> 
                <telerikNavigation:RadTreeViewItem Header="Outbox" 
                        DefaultImageSrc="/TreeView/Images/Outlook/outbox.png" /> 
                <telerikNavigation:RadTreeViewItem Header="Sent Items" 
                        DefaultImageSrc="/TreeView/Images/Outlook/sent.png" /> 
                <telerikNavigation:RadTreeViewItem Header="Search Folder" 
                        DefaultImageSrc="/TreeView/Images/Outlook/searchFolder.png" 
                        IsExpanded="True"
                    <telerikNavigation:RadTreeViewItem Header="From Follow up" 
                            DefaultImageSrc="/TreeView/Images/Outlook/search.png" /> 
                    <telerikNavigation:RadTreeViewItem Header="Large Mail" 
                            DefaultImageSrc="/TreeView/Images/Outlook/search.png" /> 
                    <telerikNavigation:RadTreeViewItem Header="Unread Mail" 
                            DefaultImageSrc="/TreeView/Images/Outlook/search.png" /> 
                </telerikNavigation:RadTreeViewItem> 
            </telerikNavigation:RadTreeViewItem> 
        </telerikNavigation:RadTreeView> 
 

This works great for me. I don't see why a <user.resources> section is used in the documentation. Adds more complexity. You can easily create event handlers like this.

contextMenuItem.Click += new Telerik.Windows.RadRoutedEventHandler(contextMenuItem_Click);

where your radtreeviewitem has an x:name="contextMenuItem"

Hope this helps people who are banging their heads with this one.

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 17 May 2010, 01:14 PM
Hi Jerry,

Thank you for your valuable feedback. We are constantly trying to improve our controls and the accompanying documentation therefore your feedback is more than welcome. I've logged your request in our PITS under the name "TreeView: Simplify ContextMenu article in Documentation" and it will be available for tracking tomorrow the latest. Let me know if you have additional questions or comments on the topic. I'd be glad to further assist you.

Kind regards,
Kiril Stanoev
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.
Tags
TreeView
Asked by
JDT
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or