Prism適配器
DevExpress.Xpf.PrismAdapters.v23.1程序集為以下控件提供了Prism 5_和Prism 6/7/8 _適配器:
- LayoutGroup
- DocumentGroup
- TabbedGroup
- LayoutPanel
- DXTabControl
- NavigationFrame
- NavBarControl
- NavBarGroup
通過靜態(tài)AdapterFactory.Make方法檢索適配器實例。
下面的代碼片段演示了如何在Prism Unity引導(dǎo)程序中注冊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; } // ... }
點(diǎn)擊復(fù)制
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; } // ... }
點(diǎn)擊復(fù)制
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
點(diǎn)擊復(fù)制
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
點(diǎn)擊復(fù)制
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; } // ... }
點(diǎn)擊復(fù)制
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
點(diǎn)擊復(fù)制
由于Prism在處理FrameworkContentElement后代(特別是NavBarGroup和NavigationFrame)適配器方面的限制,需要在XAML中使用DXRegionManager類指定地區(qū)名稱。請看下面的代碼片段:
XAML:
<UserControl ... xmlns:dxprism="http://schemas.devexpress.com/winfx/2008/xaml/prism"> <dxn:NavBarControl> <dxn:NavBarGroup dxprism:DXRegionManager.RegionName="NavBarControlRegion" /> </dxn:NavBarControl> </UserControl>
點(diǎn)擊復(fù)制
如果未指定靜態(tài)DXRegionManager.PrismVersion屬性的值,則DXRegionManager嘗試基于注冊的適配器和加載的程序集獲取當(dāng)前使用的Prism版本,建議手動將此屬性設(shè)置為適當(dāng)?shù)闹怠?
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)); } }
點(diǎn)擊復(fù)制
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
點(diǎn)擊復(fù)制
示例