I'm using Caliburn.Micro I try do create dynamic ItemMenu in a existing Menu. In the View "MainView.xaml" I put
<Menu Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="4" Margin="0">
<MenuItem Header="_File">
<MenuItem Header="_Open" Name="FileOpen"/>
<ContentControl x:Name="MenuItems" />
<Separator/>
<ItemsControl ItemsSource="{Binding RFL}"/>
<!--<common:RecentFileList x:Name="RecentFileList">
</common:RecentFileList>-->
</MenuItem>
In the ViewModel "MainViewModel" I have this
public BindableCollection<MenuItem> MenuItems
{
get { return menuItems; }
set { menuItems = value; }
}
public void MenuItem_New()
{
}
public MainViewModel()
{
recentFileList.MenuClick += (s, e) => SendPathToUserControls(e.Filepath);
MenuItems = new BindableCollection<MenuItem>();
this._menu = new MenuViewModel();
MenuItem menuItem = new MenuItem( );
menuItem.Header = "Sous Menu 1";
menuItem.Name = "SousMenu1";
MenuItems.Add(menuItem);
}
And when I execute I have this message :
How can I create dynamic MenuItemg without having to do a View And subsidiary question, how to raise the command with a parameter that contains the text of the menuitem (I'm trying to do a Most Recent File)