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

Several ContextMenus on same xaml file

3 Answers 113 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
frederic szymczak
Top achievements
Rank 1
frederic szymczak asked on 03 Jun 2010, 10:29 AM
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

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 08 Jun 2010, 07:08 AM
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.
0
frederic szymczak
Top achievements
Rank 1
answered on 14 Jun 2010, 09:48 PM
Hello Hristo,

Sorry for the late.

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


Thank you.
0
Vlad
Telerik team
answered on 15 Jun 2010, 06:18 AM
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.
Tags
ContextMenu
Asked by
frederic szymczak
Top achievements
Rank 1
Answers by
Hristo
Telerik team
frederic szymczak
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or