2.8 KiB
2.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T16:29:20.553191+00:00 | zai-org/GLM-5-FP8 | 1 | 0b1fef2bce493cf0 |
RegionAdapters
Purpose
This module provides a Prism region adapter for StackPanel controls, enabling the Prism region navigation framework to manage child elements within a StackPanel. It bridges the gap between Prism's region management system and WPF's StackPanel by synchronizing the region's views collection with the panel's visual children.
Public Interface
StackPanelRegionAdapter (class, inherits RegionAdapterBase<StackPanel>)
StackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)- Constructor accepting the region behavior factory required by the base class.protected override void Adapt(IRegion region, StackPanel regionTarget)- Subscribes to the region'sViews.CollectionChangedevent and synchronizes additions and removals with theStackPanel.Childrencollection. HandlesNotifyCollectionChangedAction.AddandNotifyCollectionChangedAction.Removeactions; other actions are ignored.protected override IRegion CreateRegion()- Returns a newAllActiveRegioninstance, indicating all views in this region are considered active.
Invariants
- The
regionparameter inAdapt()may be null; the method returns early without side effects in this case. - Only
AddandRemovecollection change actions are handled;Replace,Reset, andMoveactions are silently ignored. - When removing elements, the adapter checks
regionTarget.Children.Contains(element)before attempting removal to avoid exceptions. - The region is always created as
AllActiveRegion, meaning all views are active simultaneously (no deactivation semantics).
Dependencies
Depends on:
System.Collections.Specialized(forNotifyCollectionChangedAction)System.Windows(forUIElement)System.Windows.Controls(forStackPanel)Prism.Regions(forRegionAdapterBase<T>,IRegion,IRegionBehaviorFactory,AllActiveRegion)
Depended on by: Not determinable from source alone (likely registered in application bootstrapping or module initialization).
Gotchas
- The
Removecase uses a local variableelementassigned fromelementLoopVariablein the foreach loop—this appears to be a vestigial pattern (possibly from a VB.NET conversion or older C# version) and is unnecessary in modern C# where foreach loop variables are already scoped per iteration. - No handling for
ResetorReplaceactions means bulk collection changes may not properly synchronize the UI. - The null check for
regionat the start ofAdapt()is inconsistent with typical Prism adapter patterns where a null region would indicate a framework error.