13 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:47:59.133790+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 8f96fa689f5431a2 |
RibbonControl Data Model Documentation
1. Purpose
This module defines a hierarchical data model for representing ribbon UI controls in a WPF application. It provides a set of data classes (*Data) that serve as view models for UI elements in a ribbon interface, enabling declarative construction of ribbon structures (tabs, groups, controls) with support for commands, images, tooltips, and dynamic state. The model supports standard controls (buttons, checkboxes, text boxes), menu-based controls (menu buttons, split buttons, menu items), and specialized controls (galleries, combo boxes), with built-in support for application menu structures and contextual tab groups. It is part of the DTS.Common.RibbonControl namespace and is intended to be consumed by UI rendering layers that bind to these data objects.
2. Public Interface
All classes are public and reside in the DTS.Common.RibbonControl namespace. Most implement INotifyPropertyChanged.
Base Classes
-
ControlData
Base class for all ribbon control data models. Provides common properties:
string Label,Uri LargeImage,Uri SmallImage,string ToolTipTitle,string ToolTipDescription,Uri ToolTipImage,string ToolTipFooterTitle,string ToolTipFooterDescription,Uri ToolTipFooterImage,ICommand Command,string KeyTip. All properties raisePropertyChangedon change. -
MenuButtonData : ControlData
Base class for controls that can host child controls (e.g., menu buttons, split buttons). Constructor acceptsbool isApplicationMenu. Provides:
bool IsVerticallyResizable,bool IsHorizontallyResizable,ObservableCollection<ControlData> ControlDataCollection(lazy-initialized with sample content based onViewModelDataconstants). Internally tracks_nestingDepthto limit recursive menu nesting. -
SplitButtonData : MenuButtonData
ExtendsMenuButtonData. Adds:
bool IsChecked,bool IsCheckable,ButtonData DropDownButtonData(lazy-initialized). Used for split buttons with a main action and dropdown.
Leaf Controls
-
ButtonData : ControlData
Simple button control. -
SeparatorData : ControlData
Visual separator control. -
GalleryItemData : ControlData
Item within a gallery. -
TextBoxData : ControlData
Text input control. Adds:
string Text(raisesPropertyChangedon change). -
CheckBoxData : ControlData
Check box control. Adds:
bool IsChecked(raisesPropertyChangedon change). -
RadioButtonData : ControlData
Radio button control. Adds:
bool IsChecked(raisesPropertyChangedon change). -
ToggleButtonData : ControlData
Toggle button control. Adds:
bool IsChecked(raisesPropertyChangedon change).
Menu Hierarchy
-
MenuItemData : SplitButtonData
Menu item. Constructor accepts optionalbool isApplicationMenu. Used for standard menu items. -
SplitMenuItemData : MenuItemData
Split menu item. Constructor accepts optionalbool isApplicationMenu. -
ApplicationMenuItemData : MenuItemData
Menu item specifically for the application menu. Constructor accepts optionalbool isApplicationMenu. -
ApplicationSplitMenuItemData : SplitMenuItemData
Split menu item for the application menu. Constructor accepts optionalbool isApplicationMenu. -
ComboBoxData : MenuButtonData
Combo box control (inherits fromMenuButtonData, notControlData).
Container Classes
-
GalleryCategoryData : ControlData
Category within a gallery. Provides:
ObservableCollection<GalleryItemData> GalleryItemDataCollection(lazy-initialized with 10 items perViewModelData.GalleryItemCount, pre-populated with sample data includingViewModelData.DefaultCommand).
Generic variant:GalleryCategoryData<T>providesObservableCollection<T> GalleryItemDataCollection. -
GalleryData : ControlData
Gallery control. Provides:
ObservableCollection<GalleryCategoryData> CategoryDataCollection(lazy-initialized with 3 categories perViewModelData.GalleryCategoryCount, each with sample data),
GalleryItemData SelectedItem,bool CanUserFilter.Generic variant:
GalleryData<T>providesObservableCollection<GalleryCategoryData<T>> CategoryDataCollection,T SelectedItem,bool CanUserFilter. -
GroupData : ControlData
Ribbon group. Constructor takesstring header. Provides:
ObservableCollection<ControlData> ControlDataCollection(lazy-initialized with sample controls: 1ButtonData, 1ToggleButtonData, 1RadioButtonData, 1CheckBoxData, 1TextBoxData, 1MenuButtonData, 1SplitButtonData, 1ComboBoxData, perViewModelDataconstants). -
TabData : INotifyPropertyChanged
Ribbon tab. Constructor takes optionalstring header. Provides:
string Header,string ContextualTabGroupHeader,bool IsSelected,
ObservableCollection<GroupData> GroupDataCollection(lazy-initialized with 3 groups perViewModelData.GroupCount). -
ContextualTabGroupData : INotifyPropertyChanged
Contextual tab group container. Constructor takes optionalstring header. Provides:
string Header,bool IsVisible,
ObservableCollection<TabData> TabDataCollection. -
RibbonData : INotifyPropertyChanged
Top-level ribbon model. Provides:
ObservableCollection<TabData> TabDataCollection(lazy-initialized with 4 tabs; first 2 assigned to contextual tab groups),
ObservableCollection<ContextualTabGroupData> ContextualTabGroupDataCollection(lazy-initialized with 2 groups),
MenuButtonData ApplicationMenuData(lazy-initialized with sample data andisApplicationMenu=true).
Static ViewModel Provider
ViewModelData
Static class providing:internal const intconstants defining default counts for various control types (e.g.,TabCount = 4,ButtonCount = 1,GalleryItemCount = 10, etc.).RibbonData RibbonData(thread-static singleton).ICommand DefaultCommand(aDelegateCommandthat alwaysCanExecuteand does nothing inExecute).
3. Invariants
-
Control hierarchy constraints:
RibbonDatacontainsTabDatainstances, each of which belongs to aContextualTabGroupData(viaContextualTabGroupHeader) or none.TabDatacontainsGroupDatainstances.GroupDatacontainsControlDatainstances (including derived types).MenuButtonDataand its descendants (SplitButtonData,ComboBoxData,MenuItemData, etc.) may contain nestedControlDatainstances.GalleryDatacontainsGalleryCategoryData, which containsGalleryItemData.- Nesting depth for menu items is limited to
ViewModelData.MenuItemNestingCount(2) inMenuButtonData.ControlDataCollectioninitialization.
-
Initialization behavior:
- Collections (
TabDataCollection,GroupDataCollection,ControlDataCollection,CategoryDataCollection, etc.) are lazily initialized on first access and reused thereafter. - Sample data (images, labels, tooltips) in collections is hardcoded using
/Common;component/RibbonControl/Images/Paste_16x16.pngandPaste_32x32.pngURIs. RibbonData.TabDataCollectioninserts tabs in reverse order (ifromTabCountdown to 1) to ensure correct visual ordering.
- Collections (
-
Property change notifications:
- All properties in
ControlDataand derived classes raisePropertyChangedonly when the new value differs from the current value (exceptGalleryData<T>.SelectedItem, which usesEqualsfor comparison). RibbonData,TabData,ContextualTabGroupDataimplementINotifyPropertyChangedand raise events for their properties.
- All properties in
-
Application menu flag:
- The
isApplicationMenuconstructor parameter is passed down throughMenuItemData,SplitMenuItemData,ApplicationMenuItemData,ApplicationSplitMenuItemData, andMenuButtonDatato influence initialization logic (e.g., which*Datatypes are instantiated inControlDataCollection).
- The
4. Dependencies
Internal Dependencies (within module)
ViewModelData: Used byGalleryCategoryData,GalleryData,MenuButtonData,GroupData,RibbonDatato populate collections with default counts and sample data.ViewModelData.DefaultCommand: Used as the defaultCommandfor sample controls.ViewModelDataconstants: Drive initialization logic inGalleryCategoryData,GalleryData,MenuButtonData,GroupData,RibbonData.
External Dependencies
System,System.Collections.ObjectModel,System.ComponentModel,System.Windows.Input: Standard .NET libraries for collections, property change notifications, and commands.Microsoft.Practices.Prism.Commands: Used forDelegateCommandinViewModelData.DefaultCommand.- WPF image URIs: Hardcoded URIs like
/Common;component/RibbonControl/Images/Paste_16x16.pngimply dependencies on embedded resources in theCommonassembly.
Inferred Usage
- This module is intended to be used by UI rendering layers (e.g., XAML views) that bind to
RibbonData,TabData,GroupData, andControlDatainstances. RibbonDatais the primary entry point for ribbon configuration.
5. Gotchas
- Thread-static singleton:
ViewModelData.RibbonDatais[ThreadStatic], meaning each thread gets its own instance. This may cause unexpected behavior if ribbon data is shared across threads without synchronization. - Hardcoded image paths: URIs like
/Common;component/RibbonControl/Images/Paste_16x16.pngassume specific resource paths and assembly names. Changes to resource structure will break sample data. - Nesting depth limit:
MenuButtonData.ControlDataCollectionstops adding nested items after_nestingDepthreachesViewModelData.MenuItemNestingCount(2). This limit is not exposed or configurable. ComboBoxDatainheritance:ComboBoxDatainherits fromMenuButtonData, notControlData. This may be non-intuitive and implies it hasControlDataCollectionandIsVerticallyResizable/IsHorizontallyResizableproperties.SplitButtonDatavsSplitMenuItemData: Both haveIsCheckableandIsChecked, butSplitButtonDatais a leaf control in groups, whileSplitMenuItemDatais part of a menu hierarchy. Their behaviors may differ contextually.GalleryData.SelectedItemtype mismatch: Non-genericGalleryData.SelectedItemisGalleryItemData, while genericGalleryData<T>.SelectedItemisT. Ensure type consistency when using the generic variant.ControlDatavsControlDataCollection:ControlDataCollectionis initialized only once per instance and reused. Modifying the collection after first access may have side effects if other code expects a fixed structure.- No validation: No validation is performed on property values (e.g.,
Label,KeyTip,Header). Invalid values may cause UI rendering issues. IsApplicationMenuflag propagation: TheisApplicationMenuflag is passed to constructors but only used inMenuButtonDatainitialization logic. Its effect onMenuItemData/SplitMenuItemDatadescendants is not evident from the source (they all accept the parameter but do not store or use it beyond base constructor calls).