I want to use a MenuTool within a XamRibbon binding it to a custom list of my own from my View Model. This works find and I do see my list in the MenuTool. But whenever the user clicks on one of the items in the Menu Tool, I want to capture that as a Command in my View Model with the Command Parameter being the item clicked on. I don't find a way of doing it. How can I do this?
I am actually trying the MenuTool using the Themes in Infragistics. I want to have the list of Themes from ViewModel and also a SelectedTheme. The MenuTool should start with the "SelectedTheme" and whenever the theme is changed (by selecting from the list of themes), the SelectedTheme should be reset and the Theme of the ribbon should change. How do I do that? I don't really see any property like SelectedItem etc and also the Commanding is not working whenever I change the selection from the menu.
Hello,
Thank you for your post. I have been looking into it and I can suggest you see these forum threads:
http://es.infragistics.com/community/forums/t/10352.aspx
http://es.infragistics.com/community/forums/p/24492/245962.aspx
http://es.infragistics.com/community/forums/t/27446.aspx
where similar questions like yours are already discussed. Please let us know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Hi Stefan,
I am also try to use the MenuTool in MVVM. Trying to do what the original poster likes to do, I looked through all your suggested threads, however, I was not able to get the MenuTool to work.
Here's the XAML:
<igRibbon:MenuTool Caption="Status" ItemsSource="{Binding MenuItems}"> <igRibbon:MenuTool.ItemContainerStyle> <Style TargetType="{x:Type igRibbon:ToolMenuItem}"> <Setter Property="Command" Value="{Binding SetStatusCommand}"/> <Setter Property="CommandParameter" Value="{Binding}"/> </Style> </igRibbon:MenuTool.ItemContainerStyle> </igRibbon:MenuTool>
Here's the VM:
public class ViewModel:ViewModelBase
{
public ViewModel()
MenuItems = new ObservableCollection<string> { "Active", "InActive", "Test" };
SetStatusCommand = new DelegateCommand<string>(SetStatus);
}
public DelegateCommand<string> SetStatusCommand { get; set; }
private ObservableCollection<string> _MenuItems;public ObservableCollection<string> MenuItems{ get { return _MenuItems; } set { if (value != _MenuItems) { _MenuItems = value; RaisePropertyChanged(); } }}
private void SetStatus(string status) { var parameter = status; }
When I click on the item from the menu drop-down, the SetStatusCommand was not fired.
What did I do wrong?
If you can prepare a simple sample showing how to use MenuTool in MVVM will be a great help.
Thank you very much.