logo Devexpress WPF控件文档中心
文档首页>>Devexpress WPF控件文档中心>>Prism适配器

Prism适配器


立即下载DevExpress WPF

DevExpress.Xpf.PrismAdapters.v23.1程序集为以下控件提供了Prism 5_和Prism 6/7/8 _适配器:

  • LayoutGroup
  • DocumentGroup
  • TabbedGroup
  • LayoutPanel
  • DXTabControl
  • NavigationFrame
  • NavBarControl
  • NavBarGroup

通过静态AdapterFactory.Make方法检索适配器实例。

下面的代码片段演示了如何在Prism Unity引导程序中注册DevExpress Prism适配器。

Prism 5/6

C#:

class PrismBootstrapper : MefBootstrapper {
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() {
var mappings = base.ConfigureRegionAdapterMappings();
var factory = Container.GetExportedValue<IRegionBehaviorFactory>();
mappings.RegisterMapping(typeof(DXTabControl),
DevExpress.Xpf.Prism.AdapterFactory.Make<RegionAdapterBase<DXTabControl>>(factory));
return mappings;
}
// ...
}

点击复制

C#:

using Microsoft.Practices.Unity;
class PrismBootstrapper : UnityBootstrapper {
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() {
var mappings = base.ConfigureRegionAdapterMappings();
var factory = Container.Resolve<IRegionBehaviorFactory>();
mappings.RegisterMapping(typeof(DXTabControl),
DevExpress.Xpf.Prism.AdapterFactory.Make<RegionAdapterBase<DXTabControl>>(factory));
return mappings;
}
// ...
}

点击复制

VB.NET:

Friend Class PrismBootstrapper
Inherits MefBootstrapper

Protected Overrides Function ConfigureRegionAdapterMappings() As RegionAdapterMappings
Dim mappings = MyBase.ConfigureRegionAdapterMappings()
Dim factory = Container.GetExportedValue(Of IRegionBehaviorFactory)()
mappings.RegisterMapping(GetType(DXTabControl), DevExpress.Xpf.Prism.AdapterFactory.Make(Of RegionAdapterBase(Of DXTabControl))(factory))
Return mappings
End Function
' ...
End Class

点击复制

VB.NET:

Imports Microsoft.Practices.Unity
Friend Class PrismBootstrapper
Inherits UnityBootstrapper

Protected Overrides Function ConfigureRegionAdapterMappings() As RegionAdapterMappings
Dim mappings = MyBase.ConfigureRegionAdapterMappings()
Dim factory = Container.Resolve(Of IRegionBehaviorFactory)()
mappings.RegisterMapping(GetType(DXTabControl), DevExpress.Xpf.Prism.AdapterFactory.Make(Of RegionAdapterBase(Of DXTabControl))(factory))
Return mappings
End Function
' ...
End Class

点击复制

Prism 6

C#:

using Autofac;
class PrismBootstrapper : AutofacBootstrapper {
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() {
var mappings = base.ConfigureRegionAdapterMappings();
var factory = Container.Resolve<IRegionBehaviorFactory>();
mappings.RegisterMapping(typeof(DXTabControl),
DevExpress.Xpf.Prism.AdapterFactory.Make<RegionAdapterBase<DXTabControl>>(factory));
return mappings;
}
// ...
}

点击复制

VB.NET:

Imports Autofac
Friend Class PrismBootstrapper
Inherits AutofacBootstrapper

Protected Overrides Function ConfigureRegionAdapterMappings() As RegionAdapterMappings
Dim mappings = MyBase.ConfigureRegionAdapterMappings()
Dim factory = Container.Resolve(Of IRegionBehaviorFactory)()
mappings.RegisterMapping(GetType(DXTabControl), DevExpress.Xpf.Prism.AdapterFactory.Make(Of RegionAdapterBase(Of DXTabControl))(factory))
Return mappings
End Function
' ...
End Class

点击复制

由于Prism在处理FrameworkContentElement后代(特别是NavBarGroup和NavigationFrame)适配器方面的限制,需要在XAML中使用DXRegionManager类指定地区名称。请看下面的代码片段:

XAML:

<UserControl ...
xmlns:dxprism="http://schemas.devexpress.com/winfx/2008/xaml/prism">
<dxn:NavBarControl>
<dxn:NavBarGroup dxprism:DXRegionManager.RegionName="NavBarControlRegion" />
</dxn:NavBarControl>
</UserControl>

点击复制

如果未指定静态DXRegionManager.PrismVersion属性的值,则DXRegionManager尝试基于注册的适配器和加载的程序集获取当前使用的Prism版本,建议手动将此属性设置为适当的值。

Prism 7/8

提示:Prism 8支持在20.2.5及更新版本中可用。

C#:

public partial class App : PrismApplication {
protected override void ConfigureRegionAdapterMappings(RegionAdapterMappings regionAdapterMappings) {
base.ConfigureRegionAdapterMappings(regionAdapterMappings);
var factory = Container.Resolve<IRegionBehaviorFactory>();
regionAdapterMappings.RegisterMapping(typeof(DXTabControl), DevExpress.Xpf.Prism.AdapterFactory.Make<RegionAdapterBase<DXTabControl>>(factory));
}
}

点击复制

VB.NET:

Partial Public Class App
Inherits PrismApplication
Protected Overrides Sub ConfigureRegionAdapterMappings(ByVal regionAdapterMappings As RegionAdapterMappings)
MyBase.ConfigureRegionAdapterMappings(regionAdapterMappings)
Dim factory = Container.Resolve(Of IRegionBehaviorFactory)()
regionAdapterMappings.RegisterMapping(GetType(DXTabControl), AdapterFactory.Make(Of RegionAdapterBase(Of DXTabControl))(factory))
End Sub
End Class

点击复制

示例

在线咨询
联系我们

客服热线
023-68661681

QQ客服

意见反馈


添加微信获专业服务

TOP