Hi,
The following works when the context menu is declared in the TreeView directly.
However when placed my context menu inside the Data template as I only want a context menu with leave items,
it does not work anymore. I tried to change the binding with the relativesouce but no luck. we are using the MVVM. The commands are in the ViewModel of the view.
Do you have any examples with it?
Thanks
The following works when the context menu is declared in the TreeView directly.
<telerik:RadTreeView Name="radTreeView" ExpanderStyle="{StaticResource ExpanderStyle}" ItemsSource="{Binding Path=EnvironmentMenuDataSource}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ItemTemplate="{StaticResource EnvironmentMenu}"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu Opened="RadTreeViewContextMenuOpened"> <telerik:RadMenuItem Header="{Binding Path=SelectedItem.ContextCommandName}" Command="{Binding Path=ViewListCommand}" CommandParameter="{Binding SelectedItem}"> <telerik:RadMenuItem.Icon> <Image Source="../Images/Menu/Blue.png" Stretch="Uniform" /> </telerik:RadMenuItem.Icon> </telerik:RadMenuItem> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </telerik:RadTreeView>However when placed my context menu inside the Data template as I only want a context menu with leave items,
<DataTemplate x:Key="EntityMenu"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="0.35*"/> <ColumnDefinition Width="0.65*"/> </Grid.ColumnDefinitions> <Image Source="{Binding ImageUrl, Mode=OneWay}" Width="16" Height="16"/> <TextBlock Margin="3,0,0,0" Grid.Column="1" TextWrapping="Wrap" Text="{Binding Name, Mode=OneWay}"> <telerik:RadTreeView Name="radTreeView" ExpanderStyle="{StaticResource ExpanderStyle}" ItemsSource="{Binding Path=EnvironmentMenuDataSource}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ItemTemplate="{StaticResource EnvironmentMenu}"> <telerik:RadContextMenu.ContextMenu> <telerik:RadContextMenu Opened="RadTreeViewContextMenuOpened"> <telerik:RadMenuItem Header="{Binding Path=SelectedItem.ContextCommandName}" Command="{Binding Path=ViewListCommand}" CommandParameter="{Binding SelectedItem}"> <telerik:RadMenuItem.Icon> <Image Source="../Images/Menu/Blue.png" Stretch="Uniform" /> </telerik:RadMenuItem.Icon> </telerik:RadMenuItem> </telerik:RadContextMenu> </telerik:RadContextMenu.ContextMenu> </telerik:RadTreeView> </TextBlock> </Grid> </DataTemplate> <HierarchicalDataTemplate x:Key="EnvironmentMenu" ItemTemplate="{StaticResource EntityMenu}" ItemsSource="{Binding EntityMenus}"> <TextBlock Text="{Binding Name}" /> </HierarchicalDataTemplate>it does not work anymore. I tried to change the binding with the relativesouce but no luck. we are using the MVVM. The commands are in the ViewModel of the view.
Do you have any examples with it?
Thanks