Several ContextMenus on same xaml file

4 posts, 0 answers
  1. frederic szymczak
    frederic szymczak avatar
    9 posts
    Member since:
    Jul 2009

    Posted 03 Jun 2010 Link to this post

    Hi,

    I am trying to use several radcontextmenu on same xaml page. And graphically it works fine . But on my output I have serveral errors  :

     

     
    System.Windows.Data Error: 4 : Cannot find source for binding with reference   
    'RelativeSource FindAncestor,   
    AncestorType='Telerik.Windows.Controls.RadContextMenu'AncestorLevel='1''.   
    BindingExpression:Path=DataContext.SelectIrisV2CodesCommand; DataItem=null;   
    target element is 'EventToCommand' (HashCode=11696593); target property is   
    'Command' (type 'ICommand')


    This error happens when i open successively two different radcontextmenu.
    Scenario :
    - The first radcontextMenu clicked on, contains only leaves
    - The second radcnctextMenu clicked on, contains on first level only root nodes (Role = Submenuheader?)

    Below the code of my page :

     

     

    <Style x:Key="IrisRadMenuItemStyle" TargetType="{x:Type telerik:RadMenuItem}">   
         <Setter Property="Template">   
            <Setter.Value> 
                <ControlTemplate TargetType="{x:Type telerik:RadMenuItem}">   
                    <Grid x:Name="RootElement" Background="{TemplateBinding Background}" Margin="2" >   
                        <i:Interaction.Triggers>   
                            <i:EventTrigger EventName="MouseLeftButtonDown">   
                                <cmd:EventToCommand Command="{Binding DataContext.SelectIrisV2CodesCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerikNavigation:RadContextMenu}}, Mode=OneWay}" CommandParameter="{Binding}" />   
                            </i:EventTrigger>   
                        </i:Interaction.Triggers> 
                            ...   
     
             </Setter.Value>   
        </Setter>   
        <Style.Triggers>   
            <Trigger Property="Role" Value="SubmenuHeader">   
                <Setter Property="Template">   
     
                    <Setter.Value>   
                        <ControlTemplate TargetType="{x:Type telerik:RadMenuItem}">   
                        <Grid x:Name="RootElement" Background="{TemplateBinding Background}" Margin="2">   
                        <i:Interaction.Triggers> 
                            <i:EventTrigger EventName="MouseEnter">   
                                <cmd:EventToCommand Command="{Binding DataContext.ShowIrisCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerikNavigation:RadContextMenu}}, Mode=OneWay}" CommandParameter="{Binding}" />   
     
                            </i:EventTrigger>   
                        </i:Interaction.Triggers> 
                        ...  
            </Trigger>   
        </Style.Triggers>   
    </Style>   
     
    <ToggleButton Grid.Row="1" Grid.Column="2" Width="20" IsChecked="{Binding IsOpen, ElementName=Nav, Mode=TwoWay}">  
        <telerikNavigation:RadContextMenu.ContextMenu > 
            <telerikNavigation:RadContextMenu EventName="MouseLeftButtonDown" Name="Nav"   
    ItemContainerStyle="{DynamicResource IrisRadMenuItemStyle}" Style="{DynamicResource IrisRadContextMenuStyle}" ItemsSource="{Binding IrisCodes}" >   
     
                <telerikNavigation:RadContextMenu.ItemTemplate>   
                    <HierarchicalDataTemplate ItemsSource="{Binding IrisCodes}" />   
                </telerikNavigation:RadContextMenu.ItemTemplate>   
            </telerikNavigation:RadContextMenu>   
        </telerikNavigation:RadContextMenu.ContextMenu>   
        <Image Source="/Solmis.Client;component/Images/16/view.png" />   
    </ToggleButton>   
     
     
    ...  
     
     
    <ToggleButton Grid.Row="2" Grid.Column="2" Width="20" IsChecked="{Binding IsOpen, ElementName=NavCOE, Mode=TwoWay}">   
        <telerikNavigation:RadContextMenu.ContextMenu >   
            <telerikNavigation:RadContextMenu EventName="MouseLeftButtonDown" Name="NavCOE"   
    ItemContainerStyle="{DynamicResource IrisRadMenuItemStyle}" Style="{DynamicResource IrisRadContextMenuStyle}" ItemsSource="{Binding IrisCodes}" >   
     
                <telerikNavigation:RadContextMenu.ItemTemplate>   
                    <HierarchicalDataTemplate ItemsSource="{Binding IrisCodes}" />   
                </telerikNavigation:RadContextMenu.ItemTemplate>   
            </telerikNavigation:RadContextMenu>   
        </telerikNavigation:RadContextMenu.ContextMenu>   
     
        <Image Source="/Solmis.Client;component/Images/16/view.png" />   
     
    </ToggleButton> 

     

     

     


    It seams there is only one instance of RadContextMenu for all RadContextMenu i have in my page.. If it's the case, i would know why the role=sumbmenuheader style is also applied on leaves ?

    Thank you in advance for your help

  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 08 Jun 2010 Link to this post

    Hello frederic szymczak,

    Could you send us sample project so that we can investigate it?

    Kind regards,
    Hristo
    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. frederic szymczak
    frederic szymczak avatar
    9 posts
    Member since:
    Jul 2009

    Posted 14 Jun 2010 Link to this post

    Hello Hristo,

    Sorry for the late.

    Could you tell me, how can I add an attached file on this thread ?


    Thank you.
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 15 Jun 2010 Link to this post

    Hello,

     It will be better to use our support system since attachments in forums are size (and content) limited. 

    Sincerely yours,
    Vlad
    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.
Back to Top