【发布时间】:2022-01-06 05:13:23
【问题描述】:
我有一个 Prism 自定义区域适配器,用于在 DevExpress“DocumentGroup”的不同选项卡中显示每个视图。
为了做到这一点,我有以下 RegionAdapter:
public class DocumentGroupRegionAdapter : RegionAdapterBase<DocumentGroup>
{
public DocumentGroupRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
: base(regionBehaviorFactory)
{
}
protected override void Adapt(IRegion region, DocumentGroup regionTarget)
{
region.Views.CollectionChanged += (sender, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Add)
{
foreach (FrameworkElement element in args.NewItems)
{
DocumentPanel documentPanel = new DocumentPanel {Content = element, DataContext = element.DataContext};
regionTarget.Items.Add(documentPanel);
}
}
};
}
protected override IRegion CreateRegion()
{
return new AllActiveRegion();
}
}
AllActiveRegion 为:
public class AllActiveRegion : Region
{
public override IViewsCollection ActiveViews
{
get { return Views; }
}
public override void Deactivate(object view)
{
throw new InvalidOperationException(Resources.DeactiveNotPossibleException);
}
}
我们为这个区域注册了几个视图:
_regionManager.RegisterViewWithRegion(Regions.MainSections, typeof(Views.Layout.RootView));
_regionManager.RegisterViewWithRegion(Regions.MainSections, typeof(Views.Configure.RootView));
_regionManager.RegisterViewWithRegion(Regions.MainSections, typeof(Views.Dashboard.RootView));
到目前为止它运行良好,但现在,在某些选项上,我们需要激活其中一个选项卡。这将通过调用item.IsActive = true 来完成。
如何指定我也想导航的项目?
我应该覆盖什么来设置这个活动项目?
【问题讨论】:
标签: wpf xaml devexpress prism