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

HierarchicalDataTemplate & Context Menu

1 Answer 123 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Srinivas
Top achievements
Rank 1
Srinivas asked on 15 Sep 2009, 10:14 PM
Hi,

I am trying to use HierarchicalDataTemplate to populate the tree items from an ObservableCollection and everything is working fine, but the context menu that I added to the tree is not getting opened. I want to add a context menu to the tree in this scenario. Any help is appreciated.

Thanks

code:
<UserControl.Resources>
        <telerik:HierarchicalDataTemplate x:Key="itemTemplate" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}"
                           Margin="0,0,5,0"
                           />
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
  <Grid x:Name="LayoutRoot">
        <telerikNavigation:RadTreeView x:Name="treeView"
                                   ItemTemplate="{StaticResource itemTemplate}">
            <telerikNavigation:RadContextMenu.ContextMenu>
                <telerikNavigation:RadContextMenu x:Name="contextMenu" Opened="contextMenu_Opened"
                                                                            ItemClick="contextMenu_ItemClick">
                    <telerikNavigation:RadMenuItem Header="Add New Folder" x:Name="additem" />
                    <telerikNavigation:RadMenuItem Header="Add New Item" x:Name="addfold" />
                    <telerikNavigation:RadMenuItem Header="Edit " x:Name="edit" />
                    <telerikNavigation:RadMenuItem Header="Remove" x:Name="remove" />
                </telerikNavigation:RadContextMenu>
            </telerikNavigation:RadContextMenu.ContextMenu>
        </telerikNavigation:RadTreeView>
    </Grid>

1 Answer, 1 is accepted

Sort by
0
Bobi
Telerik team
answered on 18 Sep 2009, 11:58 AM
Hello Srinivas,


Thank you fro the interest in RadControls for Silverlight.

Please take a look at the following example:
http://demos.telerik.com/silverlight/#TreeView/AddRemoveDisable

Another more complex example you can find in the following blog post:

http://blogs.telerik.com/valerihristov/posts/09-04-27/attaching_a_contextmenu_on_a_treeview_with_radcontrols_for_silverlight.aspx

I hope that this will help you.
If you still have any questions and difficulties implementing the desired functionality please send us some sample code in order to fix it.


Sincerely yours,
Boryana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TreeView
Asked by
Srinivas
Top achievements
Rank 1
Answers by
Bobi
Telerik team
Share this question
or