The project is composed using the WPF MVVMLight Framework.
The Object Is to: create a set of ToolBars with each ToolBar also having it's ToolBar Items (Buttons for the sake of clarity) created dynnamically, using just the necessary "skeleton" code in XAML.
The endeavor to create Menus dynamically was successful by making the use of a HierarchicalDataTemplate to propagate the MenuItems for it.
With the Menu it was just creating each Menu object with an array of MenuItems inside of it.
The problem with ToolBars; however, is that there needs to be an array of ToolBars with another array of Items inside of it...
public enum SiClopsExplorerToolbarType
{
#region file
[Description( "New Folder" )]
[TypeId( 1 )]
Folder ,
[Description( "New File" )]
[TypeId( 1 )]
File ,
.
.
#endregion // file
#region edit
[Description( "Cut" )]
[TypeId( 2 )]
Cut ,
[Description( "Copy" )]
[TypeId( 2 )]
Copy ,
[Description( "Paste" )]
[TypeId( 2 )]
Paste ,
#endregion // edit
#region view
[Description( "SI-CLOPS Explorer" )]
[TypeId( 3 )]
SiClopsExplorer ,
[Description( "Publication Data" )]
[TypeId( 3 )]
PublicationData ,
#endregion // view
}
... The TypeId for each enumeration indicates which ToolBar to create and thus create Buttons for: TB 1 (File), TB 2 (Edit), TB 3 (View) for a total of three Toolbars and their Buttons.
public class ToolbarEntity
{
#region constructor
#endregion // constructor
public ToolbarEntity()
{
Toolbars = new List<ToolbarEntity>();
}
#region properties
public IList<ToolbarEntity> Toolbars { get; set; }
/// <summary>
/// The Description value of the MDI child-menu-type enumerated object is used as the display value for each menu item.
/// </summary>
public string Text { get; set; }
/// <summary>
/// An integer denoting the menu-level. Top level menus are zero. 1st sub-level menus are one, etc.
/// </summary>
public int MenuLevel { get; set; }
/// <summary>
/// Top Level menus are given a unique id so can delineate the start of the next top-level menu.
/// </summary>
public int MenuId { get; set; }
#endregion // properties
}
Above is a simple class that will be used as the MVVM "Model" in which to perform DataBinding against for the View.
For the View itself, something like the following is desired:
<ToolBarTray DockPanel.Dock="Top">
<!-- Dynamically created or hardcoded in XAML... -->
<ToolBar >
<!-- Dynamically created ToolBar items... -->
<Button />
</ToolBar>
<!-- Dynamically created or hardcoded in XAML... -->
<ToolBar >
<!-- Dynamically created ToolBar items... -->
<Button />
</ToolBar>
</ToolBarTray>
How would the Toolbars and their associated ToolBar Items be created by the ViewModel?
Thanks in advance
Ended up just using XAML for the Toolbars as placeholders and then using code for all the items.