File

projects/wms-framework/src/lib/regionsframework/adapters/AdapterForItemsControl.ts

Description

Adapter for items control Allows the use of items control to host regions

Extends

RegionAdapterBase

Index

Properties
Methods

Constructor

constructor(factory: IRegionBehaviorFactory)

Creates an instance of AdapterForItemsControl.

Parameters :
Name Type Optional
factory IRegionBehaviorFactory No

Properties

RegionBehaviorFactory
Type : IRegionBehaviorFactory
Inherited from RegionAdapterBase

Methods

Protected Adapt
Adapt(region: IRegion, regionTarget: ItemsControlModel)
Inherited from RegionAdapterBase

Adapts the content control with the specific region

Parameters :
Name Type Optional Description
region IRegion No

region to adapt

regionTarget ItemsControlModel No

content control to adapt

Returns : void
Protected CreateRegion
CreateRegion()
Inherited from RegionAdapterBase
Returns : IRegion
Protected AttachDefaultBehaviors
AttachDefaultBehaviors(region: IRegion, regionTarget: T)
Inherited from RegionAdapterBase

Attach defaults behavior to region

Parameters :
Name Type Optional
region IRegion No
regionTarget T No
Returns : void
Initialize
Initialize(regionTarget: object, regionName: string)
Inherited from RegionAdapterBase
Parameters :
Name Type Optional
regionTarget object No
regionName string No
Returns : IRegion
Public AttachBehaviors
AttachBehaviors(region: IRegion, target: any)
Inherited from RegionAdapterBaseUnTyped
Parameters :
Name Type Optional
region IRegion No
target any No
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();
  }
}

result-matching ""

    No results matching ""