Access to the context menu in resources

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    21 posts
    Member since:
    Nov 2007

    Posted 15 Oct 2013 Link to this post

    Hi,

    I have a radTreeView defined with its context menu in resources::

    <UserControl.Resources>
        <sampleData:c_treeViewData x:Key="DataSource"/>
        <Style x:Key="ItemContainerStyle" TargetType="telerik:RadTreeViewItem">
            <Setter Property="IsExpanded" Value="True"/>
        </Style>
        <DataTemplate x:Key="ItemEditTemplate">
            <Grid>
     
                <StackPanel Orientation="Horizontal">
                    <TextBox Text="{Binding Name, Mode=TwoWay}"/>
                </StackPanel>
     
            </Grid>
        </DataTemplate>
         
        <DataTemplate x:Key="c_proprietyValue">
            <TextBlock Text="{Binding Name}" FontSize="14" TextWrapping="Wrap" Width="200" />
        </DataTemplate>
     
     
        <HierarchicalDataTemplate x:Key="c_proprietyType" ItemTemplate="{StaticResource c_proprietyValue}"
           ItemsSource="{Binding propretyValues}">
            <StackPanel Orientation="Horizontal">
            <Image Source="{Binding Image}" Margin=" 0,0,6,0" Height="20" Width="20" />
            <TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="14">
                  <telerik:RadContextMenu.ContextMenu >
                        <telerik:RadContextMenu Name="rcm_context1" Opened="RadContextMenu_Opened">
                        <telerik:RadMenuItem Name="Delete" Header="Delete" />
                        <telerik:RadMenuItem Name="Contraer" Header="Collapse tree" />
                        <telerik:RadMenuItem Name="Expandir" Header="Expand tree" />
                    </telerik:RadContextMenu>
                  </telerik:RadContextMenu.ContextMenu>
                 
            </TextBlock>
            </StackPanel>
        </HierarchicalDataTemplate>
     
        <HierarchicalDataTemplate x:Key="c_block" ItemTemplate="{StaticResource c_proprietyType}"
           ItemsSource="{Binding propretyTypes}" >
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding Image}" Margin=" 0,0,6,0" Height="20" Width="20" />
                 
                <TextBlock Text="{Binding Name}" FontWeight="Bold" FontSize="16" HorizontalAlignment="Stretch">
                 
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu Opened="RadContextMenu_Opened">
                <telerik:RadMenuItem Name="Rename" Header="Rename" />
                <telerik:RadMenuItem Name="Delete" Header="Delete" />
                <telerik:RadMenuItem Name="Contraer" Header="Collapse tree" />
                <telerik:RadMenuItem Name="Expandir" Header="Expand tree" />
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>
     
                </TextBlock>
     
            </StackPanel>
        </HierarchicalDataTemplate>
     
     
     
    </UserControl.Resources>


    I want to access the context menu to change the headers of the items depending on the country. 
    Can you help me, please? I'm using VB.NET

    Thanks

  2. Daniel
    Daniel avatar
    21 posts
    Member since:
    Nov 2007

    Posted 15 Oct 2013 Link to this post

    I've found a solution to my problem, thanks anyway
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top