Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
755
Missing event in a template
posted

Hi,

I'm setting a hierarchical data template over an element programatically, the template are in the XamWebMenu.Resources node. The menu looks good, but I don't get the XamWebMenuItem_Click event. I can get the TextBlock_MouseLeftButtonDown but it doesn't cover the full menu item surface, so if you click in the icon space (at the left) nothing happens.

How can I get the event in the hierarchical template work?

How I set the template:

                    XamWebMenuItem mi = new XamWebMenuItem() { Header = "Main Menu" };
                    mi.ItemTemplate = (DataTemplate)MainMenu.Resources["MenuDataTemplate"];
                    mi.HierarchicalItemTemplate = (Infragistics.Silverlight.Controls.HierarchicalDataTemplate)MainMenu.Resources[ "htemplate" ];
                    mi.ItemsSource = web.MenuTreeRoot.Childs.WebMenuEntry.Where( wme => wme.IsWebMenuDisplayed ).ToArray();

                    MainMenu.Items.Insert(0, mi );

The Xaml:

 

                        <igMenu:XamWebMenu.Resources>
                            <DataTemplate x:Key="MenuDataTemplate">
                                <StackPanel Orientation="Horizontal">
                                    <Border Padding="3">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=Name}" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" />
                                        </StackPanel>
                                    </Border>
                                </StackPanel>
                            </DataTemplate>

                            <ig:HierarchicalDataTemplate x:Key="htemplate" ItemsSource="{Binding Path=Childs.WebMenuEntry}" ItemTemplate="{StaticResource MenuDataTemplate}">
                                <ig:HierarchicalDataTemplate.DefaultItemsContainer>
                                    <DataTemplate>
                                        <igMenu:XamWebMenuItem Header="{Binding Name}" DataContext="{Binding}" Click="XamWebMenuItem_Click">
                                        </igMenu:XamWebMenuItem>
                                    </DataTemplate>
                                </ig:HierarchicalDataTemplate.DefaultItemsContainer>
                            </ig:HierarchicalDataTemplate>
                        </igMenu:XamWebMenu.Resources>

Parents
No Data
Reply
  • 7922
    posted

    Try to set your menu item DefaultItemsContainer property to DataTemplate that you use.         

            mi.DefaultItemsContainer = (DataTemplate)MainMenu.Resources["DefaultItemContainerTemplate"];

     Another way to get click event is to use XamWebMenu.ItemClicked event

    <igMenu:XamWebMenu ItemClicked="MainMenu_ItemClicked">

Children
No Data