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
345
XamMenuItem Command Binding Dynamically and Dynamic Styling
posted

Hi Team,

I added added a XamMenu to my page. I hen added in Xaml few Menu items. One of them has sub items which are bound to ObservableCollection of type string. 

<ig:XamMenuItem x:Name="openRecent" Header="Open Recent" 
                Style="{StaticResource DarkXamMenu}"
                ItemsSource="{Binding RecentWells}">
</ig:XamMenuItem>

I encountered two problems:

1. The sub menu items do not inherit the style that I applied to the parent menu item. How do I apply the same style to the sub items that are generated dynamically?

2. I'd like the click event of these submenu items to be bound to a command in a view model. Any new item that will be generated based on the changes in the Observable collection should trigger this command and pass the text of the item (header?) as an argument.

This is basically a try to create an "Open Recent File" menu item where recent file names will be shown to the user...

How do I go about these two problems?

Thanks

Michal