-
[Prism] RegionAdapterC#/Prism 2023. 2. 1. 14:40
//StackPanelRegionAdapter.cs
using Prism.Regions; using System.Collections.Specialized; using System.Windows; using System.Windows.Controls; namespace PMLSStudio.RegionAdapter { public class StackPanelRegionAdapter : RegionAdapterBase<StackPanel> { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - StackPanelRegionAdapter(regionBehaviorFactory) /// <summary> /// 생성자 /// </summary> /// <param name="regionBehaviorFactory">영역 BEHAVIOR 팩토리 인터페이스</param> public StackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory) { } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region 채택하기 - Adapt(region, regionTarget) /// <summary> /// 채택하기 /// </summary> /// <param name="region">영역</param> /// <param name="regionTarget">영역 타겟</param> protected override void Adapt(IRegion region, StackPanel regionTarget) { region.Views.CollectionChanged += (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (FrameworkElement element in e.NewItems) { regionTarget.Children.Add(element); } } }; } #endregion #region 영역 생성하기 - CreateRegion() /// <summary> /// 영역 생성하기 /// </summary> /// <returns>영역 인터페이스</returns> protected override IRegion CreateRegion() { return new AllActiveRegion(); } #endregion } }
Prism Adapter
https://docs.devexpress.com/WPF/117848/common-concepts/prism-adapters
728x90'C# > Prism' 카테고리의 다른 글
[Prism] Register (0) 2023.02.07 [Prism] Navigation view oneTime Instance (0) 2023.02.01 [Prism] <Control> ContentRegion (0) 2023.02.01 [Prism] Call Moule Class (0) 2023.02.01 [Prism] CompositeCommand (0) 2023.01.18 댓글