C#/Prism

[Prism] RegionAdapter

딸기우유중독 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

 

Prism Adapters | WPF Controls | DevExpress Documentation

The DevExpress.Xpf.PrismAdapters.v22.2 assembly provides Prism 5 and Prism 6/7/8 adapters for the following controls: The adapter instances are retrieved via the static AdapterFactory.Make method. The code snippets below illustrate how to register the DevE

docs.devexpress.com

 

728x90