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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

128283 Jan 12,2017 05:30 AM Jan 18,2017 06:05 AM UWP 1
loading
Tags: SfMenu
Gernot Knes
Asked On January 12, 2017 05:30 AM

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

Marimuthu Sivalingam [Syncfusion]
Replied On January 18, 2017 06:05 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;