36 lines
797 B
C#
36 lines
797 B
C#
using Prism.Regions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using Autofac;
|
|
using Autofac.Core;
|
|
using System.Windows.Input;
|
|
using MAX.Core.DependencyInjection;
|
|
namespace MAX.Framework.PrismExtension;
|
|
public static class RegionManagerExtension
|
|
{
|
|
public static FrameworkElement GetView(this IRegionManager regionManager, string regionName, string target)
|
|
{
|
|
var region = regionManager.Regions[regionName];
|
|
if (region != null)
|
|
{
|
|
|
|
var viewType = IocManager.GetRegistrationType(target);
|
|
foreach (var viewItem in region.Views)
|
|
{
|
|
if (viewItem.GetType() == viewType)
|
|
{
|
|
if (viewItem is FrameworkElement fk)
|
|
{
|
|
return fk;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|