We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Binding and Sub-MenuItems - How to get the events?

Hi.
Based on my forum entry 127366 (https://www.syncfusion.com/forums/127366/binding-and-sub-menuitems) I´m now able to bind menu-items and sub-menu-items to collections in ViewModels or code behind.
I´m now struggling with the problem how to get the event when a sub-menu-item is clicked?

I tried two approaches:

Trigger the tapped event in my DataTemplate:

<UserControl.Resources>
        <DataTemplate x:Key="MenuItemInnerTemplate">
            <Grid Tag="{Binding}" Tapped="MenuItemTapped">
                <TextBlock Text="{Binding Label}"/>
            </Grid>
        </DataTemplate>
        <primitives:HierarchicalDataTemplate ItemsSource="{Binding SubMenuItems}" x:Key="MenuItemTemplate" Template="{StaticResource MenuItemInnerTemplate}">
            <primitives:HierarchicalDataTemplate.ItemTemplate>
                <primitives:HierarchicalDataTemplate ItemsSource="{Binding SubMenuItems}" Template="{StaticResource MenuItemInnerTemplate}"/>
            </primitives:HierarchicalDataTemplate.ItemTemplate>
        </primitives:HierarchicalDataTemplate>
</UserControl.Resources>

<navigation:SfMenu Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top"
                       x:Name="SfMenuControl"
                       ItemTemplate="{StaticResource MenuItemTemplate}"/>

In Code behind I´m setting the ItemsSource to a ObservableCollection of my model.
In the Tapped-Event handler I´m reading the Tag property and therefor get the assigned element from my collection.

Works for the first layer, but NOT for submenu items. Here I do not get the tapped event from my Grid control.


Second try:

In code behind when the SfMenu control is Loaded I´m trying to get the realized SfMenuItem controls via the VisualTree. But also cant get the correct submenu items.


I´m pretty sure that I´m missing something. Could you please give me an advise how to solve this problem?

Thanks in advance and best regards, Gernot

1 Reply

MS Marimuthu Sivalingam Syncfusion Team January 18, 2017 11:05 AM UTC

Hi Gernot

Thank you for contacting Syncfusion support.

We were able to reproduce the issue and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Regards,
Marimuthu S.

Loader.
Up arrow icon