3.3 KiB
3.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-17T16:07:30.415142+00:00 | zai-org/GLM-5-FP8 | 1 | dae6287a6558dc90 |
RegionAdapters
Purpose
This module provides Prism region adapters for StackPanel controls, enabling the Prism RegionManager to manage views within StackPanel containers. It allows dynamic addition and removal of UI elements in response to changes in the region's Views collection. Two nearly identical adapters are provided: StackPanelRegionAdapter and ViewerStackPanelRegionAdapter.
Public Interface
StackPanelRegionAdapter
public StackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)— Constructor accepting a behavior factory for region configuration.protected override void Adapt(IRegion region, StackPanel regionTarget)— Subscribes toregion.Views.CollectionChangedand synchronizes theStackPanel.Childrencollection. HandlesNotifyCollectionChangedAction.Addby addingUIElementitems toregionTarget.Children, andNotifyCollectionChangedAction.Removeby removing elements that exist in the panel.protected override IRegion CreateRegion()— Returns a newAllActiveRegioninstance.
ViewerStackPanelRegionAdapter
public ViewerStackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)— Constructor accepting a behavior factory.protected override void Adapt(IRegion region, StackPanel regionTarget)— Identical implementation toStackPanelRegionAdapter.Adapt.protected override IRegion CreateRegion()— Returns a newAllActiveRegioninstance.
Invariants
- If
regionisnull,Adaptreturns immediately without attaching event handlers. - Only
AddandRemovecollection change actions are handled; other actions (e.g.,Move,Replace,Reset) are ignored. - Elements are only removed from
regionTarget.ChildrenifContains(element)returnstrue. - Both adapters always create
AllActiveRegion, meaning all views in the region are considered active.
Dependencies
- Depends on:
Prism.Regions(RegionAdapterBase<T>,IRegion,IRegionBehaviorFactory,AllActiveRegion),System.Windows.Controls(StackPanel),System.Windows(UIElement),System.Collections.Specialized(NotifyCollectionChangedAction,NotifyCollectionChangedEventArgs). - Depended on by: Unclear from source alone—likely registered with Prism's region adapter mappings at application startup.
Gotchas
- Duplicate implementations:
StackPanelRegionAdapterandViewerStackPanelRegionAdapterhave identical implementations. The reason for two separate classes is unclear from source alone—possibly for different registration scopes or naming conventions in different application areas. - Missing collection actions:
Reset,Move, andReplaceactions are not handled, which could cause synchronization issues if the Views collection undergoes those operations. - Closure capture quirk: In the
Removecase, a redundant local variablevar element = elementLoopVariable;is assigned. This appears to be a historical artifact (possibly from a VB.NET conversion or older C# version) and has no functional effect in current C#.