projects/wms-framework/src/lib/regionsframework/adapters/AdapterForItemsControl.ts
Adapter for items control Allows the use of items control to host regions
Properties |
Methods |
|
constructor(factory: IRegionBehaviorFactory)
|
||||||
Creates an instance of AdapterForItemsControl.
Parameters :
|
RegionBehaviorFactory |
Type : IRegionBehaviorFactory
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:41
|
Protected Adapt | ||||||||||||
Adapt(region: IRegion, regionTarget: ItemsControlModel)
|
||||||||||||
Inherited from
RegionAdapterBase
|
||||||||||||
Defined in
RegionAdapterBase:55
|
||||||||||||
Adapts the content control with the specific region
Parameters :
Returns :
void
|
Protected CreateRegion |
CreateRegion()
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:70
|
Returns :
IRegion
|
Protected AttachDefaultBehaviors | |||||||||
AttachDefaultBehaviors(region: IRegion, regionTarget: T)
|
|||||||||
Inherited from
RegionAdapterBase
|
|||||||||
Defined in
RegionAdapterBase:71
|
|||||||||
Attach defaults behavior to region
Parameters :
Returns :
void
|
Initialize |
Initialize(regionTarget: object, regionName: string)
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:48
|
Returns :
IRegion
|
Public AttachBehaviors |
AttachBehaviors(region: IRegion, target: any)
|
Inherited from
RegionAdapterBaseUnTyped
|
Defined in
RegionAdapterBaseUnTyped:23
|
Returns :
void
|
import { IRegion } from '../IRegion';
import { RegionAdapterBase } from '../RegionAdapterBase';
import { IRegionBehaviorFactory } from '../IRegionBehaviorFactory';
import { injectable, inject } from 'tsyringe';
import { regionBehaviorFactoryInjectionToken } from '../injectionTokens';
import { AllActiveRegion } from '../AllActiveRegion';
import { ItemsControlModel } from '../../models/controls/ItemsControlModel';
/**
* Adapter for items control
* Allows the use of items control to host regions
*
* @export
* @class AdapterForItemsControl
* @extends {RegionAdapterBase<ItemsControlModel>}
* @wType Microsoft.Practices.Prism.Regions.ItemsControlRegionAdapter
*/
@injectable()
export class AdapterForItemsControl extends RegionAdapterBase<ItemsControlModel> {
/**
* Creates an instance of AdapterForItemsControl.
* @param {IRegionBehaviorFactory} factory
* @memberof AdapterForItemsControl
*/
constructor(
@inject(regionBehaviorFactoryInjectionToken) factory: IRegionBehaviorFactory
) {
super(factory);
}
/**
* Adapts the content control with the specific region
*
* @protected
* @param {IRegion} region region to adapt
* @param {ContentControlModel} regionTarget content control to adapt
* @memberof AdapterForContentControl
*/
protected Adapt(region: IRegion, regionTarget: ItemsControlModel): void {
if (region == null) throw new Error('Null value for region argument');
if (regionTarget == null)
throw new Error('Null value for regionTarget argument');
if (regionTarget.ItemsSource != null)
throw new Error('Invalid operation, items control has items source');
if (regionTarget.items.count > 0) {
for (let i in regionTarget.items) {
region.Add(regionTarget.items[i]);
}
regionTarget.items.clear();
}
regionTarget.ItemsSource = region.Views;
}
protected CreateRegion(): IRegion {
return new AllActiveRegion();
}
}