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.
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.
<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.