Dynamically binding and statically adding MenuItems - using view Models/MVVM
问题 I'm trying to have a dynamic menu item using MVVM from an observable collection. Everything worked, but then I needed to add a "add new" button to the end. I found a solution using a CompositeCollection, like here: How do I dynamically bind and statically add MenuItems? So have the following code, where TimeSpans is a collection of ViewModels: <MenuItem Header="Time Ranges"> <MenuItem.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding TimeSpans}" /> <Separator />