File

projects/wms-framework/src/lib/basecomponentmodel/FrameworkElement.ts

Description

Framework element model

Extends

UIElement

Index

Properties
Methods
Accessors

Properties

Public ActualHeight
Type : number
Decorators :
@Dependency(FrameworkElement.ActualHeightProperty)
Static ActualHeightProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'ActualHeight', 0, null )

ActualHeightProperty dependency property

Public ActualWidth
Type : number
Decorators :
@Dependency(FrameworkElement.ActualWidthProperty)
Static ActualWidthProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'ActualWidth', 0, null )

ActualWidthProperty dependency property

allowDataContextAnchestorSet
Default value : true
Public Clip
Type : any
Decorators :
@Dependency(FrameworkElement.ClipProperty)

Gets or sets the clip

Public ctxMenuManager
Type : ContextMenuManager

Instance related to a XamContextMenuComponent

Public CtxMenuOpened
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()

Context menu opened event

Private currentStyleChange
Type : string[]
Public Cursor
Type : Cursor
Decorators :
@Dependency(FrameworkElement.CursorProperty)

Gets or sets the cursor

Static CursorProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Cursor', null, null )

CursorProperty dependency property

Static DataContextProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'DataContext', null, FrameworkElement.DataContextCallback )

DataContextProperty dependency property

Public FlowDirection
Type : any
Decorators :
@Dependency(FrameworkElement.FlowDirectionProperty)

Gets or sets the flow direction

Static FlowDirectionProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'FlowDirection', null, null )

FlowDirectionProperty dependency property

Public hasFocus
Default value : false

Flag to determine if the framework element has the docus

height
Type : number
Static Readonly HeightProperty
Default value : new DependencyProperty( 'Height', Number.NaN, FrameworkElement.HeightChangeCallback )

HeightProperty dependency property

Public HorizontalAlignment
Type : HorizontalAlignment
Decorators :
@Dependency(FrameworkElement.HorizontalAlignmentProperty)

Gets or sets the horizontal alignment

Static HorizontalAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'HorizontalAlignment', HorizontalAlignment.Stretch, null )

HorizontalAlignmentProperty dependency property

Public HorizontalContentAlignment
Type : HorizontalAlignment
Decorators :
@Dependency(FrameworkElement.HorizontalContentAlignmentProperty)

Gets or sets the horizontal content alignment.

Static Readonly HorizontalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'HorizontalContentAlignment', HorizontalAlignment.Center, null )

HorizontalContentAlignment dependency property.

Protected isDefaultStyleApplied
Type : boolean

Indicates if the current style is from a default style

Public IsEnabled
Type : boolean
Decorators :
@Dependency(FrameworkElement.IsEnabledProperty)

Gets value indicating if the control is enabled

/// TODO check property defined in Control instead of framework element

Static Readonly IsEnabledProperty
Default value : new DependencyProperty( 'IsEnabled', true, FrameworkElement.IsEnabledCallback )

IsEnabledProperty dependency property

Private isFirstTimeLoad
Default value : true

Flag used to check if it is the first time loading a model or not.

Static LanguageProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Language', null, null )

LanguageProperty dependency property

Public LayoutUpdated
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Public Loaded
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Public Margin
Type : ThicknessModel
Decorators :
@Dependency(FrameworkElement.MarginProperty)

Gets or sets the margin

Static MarginProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Margin', null, null )

MarginProperty dependency property

Public maxHeight
Type : number
Decorators :
@Dependency(FrameworkElement.MaxHeightProperty)

Gets or sets max height

Static MaxHeightProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'MaxHeight', 0, null )

MaxHeightProperty dependency property

Public maxWidth
Type : number
Decorators :
@Dependency(FrameworkElement.MaxWidthProperty)

Gets or sets the max width

Static MaxWidthProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'MaxWidth', 0, null )

MaxWidthProperty dependency property

Public minHeight
Type : number
Decorators :
@Dependency(FrameworkElement.MinHeightProperty)

Gets or sets the min height

Static MinHeightProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'MinHeight', 0, null )

MinHeightProperty dependency property

Public minWidth
Type : number
Decorators :
@Dependency(FrameworkElement.MinWidthProperty)

Gets or sets the min width

Static MinWidthProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'MinWidth', 0, null )

MinWidthProperty dependency property

Public name
Type : string
Default value : ''
Static NameProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Name', null, null )

NameProperty dependency property

Private parent
Type : FrameworkElement
Default value : null
parentChangeHandler
Type : function
Public resources
Type : ResourceDictionary
Default value : new ResourceDictionary()

Resources property

Public SizeChanged
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Private sizeChangedPendingTimeout
Type : any
Public Style
Type : RuntimeStyleInfo
Decorators :
@Dependency(FrameworkElement.StyleProperty)

Gets or sets the style

Static StyleProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Style', null, FrameworkElement.StyleCallback )

StyleProperty dependency property

Public Tag
Type : any
Decorators :
@Dependency(FrameworkElement.TagProperty)

Gets or sets the tag

Static TagProperty
Default value : new DependencyProperty('Tag', null, null)

TagProperty dependency property

Public tooltip
Type : ToolTipModel
Default value : null

Instance related to a tooltip component for this control

Public ToolTipSet
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()

ToolTipSet event

Public Unloaded
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Public VerticalAlignment
Type : VerticalAlignment
Decorators :
@Dependency(FrameworkElement.VerticalAlignmentProperty)

Gets or sets the vertical alignment

Static VerticalAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'VerticalAlignment', VerticalAlignment.Stretch, null )

VerticalAlignmentProperty dependency property

Public VerticalContentAlignment
Type : VerticalAlignment
Decorators :
@Dependency(FrameworkElement.VerticalContentAlignmentProperty)

Gets or sets the vertical content alignment.

Static VerticalContentAlignmentProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'VerticalContentAlignment', VerticalAlignment.Center, null )

VerticalContentAlignment dependency property.

Public Width
Type : number
Decorators :
@Dependency(FrameworkElement.WidthProperty)

Gets or sets the width

Static WidthProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Width', Number.NaN, FrameworkElement.WidthChangeCallback )

WidthProperty dependency property

Private __internalVisibility
Type : boolean
Default value : true
Inherited from UIElement
Defined in UIElement:289
Public AllowDrop
Type : boolean
Decorators :
@Dependency(UIElement.AllowDropProperty)
Inherited from UIElement
Defined in UIElement:279

Gets or sets the allow drop value

Static AllowDropProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'AllowDrop', false, null )
Inherited from UIElement
Defined in UIElement:52

AllowDropProperty dependency property

Public AngularComponentId
Type : null
Default value : null
Inherited from UIElement
Defined in UIElement:245
Public CacheMode
Type : any
Decorators :
@Dependency(UIElement.CacheModeProperty)
Inherited from UIElement
Defined in UIElement:287

Gets or sets the cache mode value

Static CacheModeProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'CacheMode', null, null )
Inherited from UIElement
Defined in UIElement:65

CacheModeProperty dependency property

capturedMoveHandler
Type : function
Inherited from UIElement
Defined in UIElement:339
capturedUpHandler
Type : function
Inherited from UIElement
Defined in UIElement:338
Static ClipProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Clip', null, null )
Inherited from UIElement
Defined in UIElement:78

ClipProperty dependency property

Private customCSSClasses
Type : string
Default value : ''
Inherited from UIElement
Defined in UIElement:271

Custom property to save CSS classes that need to be applied to the control

Static EffectProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Effect', null, null )
Inherited from UIElement
Defined in UIElement:91

EffectProperty dependency property

Public GotFocus
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: any) => void>()
Inherited from UIElement
Defined in UIElement:229
Private hasAutoColumnGridParent
Type : boolean
Default value : false
Inherited from UIElement
Defined in UIElement:262

Custom property to know if control is inside grid with auto columns

Public IsHitTestVisible
Type : boolean
Default value : false
Decorators :
@Dependency(UIElement.IsHitTestVisibleProperty)
Inherited from UIElement
Defined in UIElement:322

IsHitTestVisible property

Static IsHitTestVisibleProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'IsHitTestVisible', null, null )
Inherited from UIElement
Defined in UIElement:104

IsHitTestVisibleProperty dependency property

Public KeyDown
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: any) => void>()
Inherited from UIElement
Defined in UIElement:225
Public KeyUp
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: any) => void>()
Inherited from UIElement
Defined in UIElement:227
Public LostFocus
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(sender: any, e: any) => void>()
Inherited from UIElement
Defined in UIElement:231
Public MouseEnter
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: any) => MouseEventArgs>()
Inherited from UIElement
Defined in UIElement:213
Public MouseLeave
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: any) => MouseEventArgs>()
Inherited from UIElement
Defined in UIElement:215
Public MouseLeftButtonDown
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: MouseEventArgs) => void>()
Inherited from UIElement
Defined in UIElement:207
Public MouseLeftButtonUp
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: MouseEventArgs) => void>()
Inherited from UIElement
Defined in UIElement:217
Public MouseMove
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: MouseEventArgs) => void>()
Inherited from UIElement
Defined in UIElement:223
Public MouseRightButtonDown
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: MouseEventArgs) => void>()
Inherited from UIElement
Defined in UIElement:210
Public MouseRightButtonUp
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(s: any, e: MouseEventArgs) => void>()
Inherited from UIElement
Defined in UIElement:220
Public Name
Type : string
Default value : ''
Inherited from UIElement
Defined in UIElement:242

Name property

Public OnModelChange
Type : function
Inherited from UIElement
Defined in UIElement:42

On model change handler reference

Public Opacity
Type : number
Decorators :
@Dependency(UIElement.OpacityProperty)
Inherited from UIElement
Defined in UIElement:253

Gets or sets the opacity value

Static OpacityMaskProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'OpacityMask', null, null )
Inherited from UIElement
Defined in UIElement:117

OpacityMaskProperty dependency property

Static OpacityProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Opacity', 1, null )
Inherited from UIElement
Defined in UIElement:130

OpacityProperty dependency property

Static ProjectionProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'Projection', null, null )
Inherited from UIElement
Defined in UIElement:143

ProjectionProperty dependency property

Public RenderSize
Type : Size
Decorators :
@Dependency(UIElement.RenderSizeProperty)
Inherited from UIElement
Defined in UIElement:297

Gets the final render size of a UIElement.

Static RenderSizeProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'RenderSize', new Size(0, 0), null )
Inherited from UIElement
Defined in UIElement:156

RenderSizeProperty dependency property

Public RenderTransform
Type : any
Decorators :
@Dependency(UIElement.RenderTransformProperty)
Inherited from UIElement
Defined in UIElement:314

Gets or sets the render transform

Public RenderTransformOrigin
Type : any
Decorators :
@Dependency(UIElement.RenderTransformOriginProperty)
Inherited from UIElement
Defined in UIElement:305

Gets or sets the render transform origin

Static RenderTransformOriginProperty
Type : DependencyProperty
Default value : new DependencyProperty('RenderTransformOrigin', null, null)
Inherited from UIElement
Defined in UIElement:169

RenderTransformOriginProperty dependency property

Static RenderTransformProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'RenderTransform', null, null )
Inherited from UIElement
Defined in UIElement:179

RenderTransformProperty dependency property

Public Spin
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent<(sender: any, e: any) => void>()
Inherited from UIElement
Defined in UIElement:233
Static UseLayoutRoundingProperty
Type : DependencyProperty
Default value : new DependencyProperty( 'UseLayoutRounding', true, null )
Inherited from UIElement
Defined in UIElement:192

UseLayoutRoundingProperty dependency property

Static VisibilityProperty
Default value : new DependencyProperty('Visibility', true, null)
Inherited from UIElement
Defined in UIElement:205

VisibilityProperty dependency property

Protected bindingExpressions
Default value : new SimpleDictionary< string, BindingExpression >()
Inherited from DependencyObject
Public BindingValidationError
Default value : new SubscriptionEvent< (sender: any, e: BindingValidationErrorEventArgs) => void >()
Inherited from DependencyObject

Event for validation errors

Public change
Type : SubscriptionEvent<void>
Default value : new SubscriptionEvent()
Inherited from DependencyObject

Infrastructure event for notifying event changes

Public Dispatcher
Type : Dispatcher
Default value : Dispatcher.GetDispatcher()
Inherited from DependencyObject
isEnableSetPropertiesRegistry
Type : boolean
Default value : true
Inherited from DependencyObject

Flag which indicates if the dependency property set mechanism is enable

Public IsInitializingBindings
Type : boolean
Default value : false
Inherited from DependencyObject

Property to determine if bindings are being initialized

previousValidationMessage
Type : string
Default value : ''
Inherited from DependencyObject
Protected properties
Type : object
Default value : {}
Inherited from DependencyObject
Private setPropertiesRegistry
Type : Map<string | boolean>
Default value : new Map()
Inherited from DependencyObject

Registry with dependencies properties which has been set

validationerr
Default value : false
Inherited from DependencyObject
validationMessagesStack
Type : Array<>
Default value : []
Inherited from DependencyObject

Keeps a queue of validation messages registered on the current Dependency Object

Methods

Public AfterContentChecked
AfterContentChecked()

Angular Lifecycle Hooks

Returns : void
Public AfterContentInit
AfterContentInit()

Angular Lifecycle Hook

Returns : void
Public AfterViewChecked
AfterViewChecked()

Angular Lifecycle Hooks

Returns : void
Public AfterViewInit
AfterViewInit()

Angular Lifecycle Hook. According to SL Documentation LayoutUpdated is the last object lifetime event to occur in the sequence before a control is ready for interaction. A setTimeout is set to ensure that it is triggered after everything is resolved.

Returns : void
Public CleanupBindingSubscriptions
CleanupBindingSubscriptions()

Clean up any subscription created for user bindings

Returns : void
Static DataContextCallback
DataContextCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

DataContext Callback Executed when the Width changes

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
Public DoCheck
DoCheck()

Angular Lifecycle Hooks

Returns : void
Public FindName
FindName(name: string)

Find an object by its Name.

Parameters :
Name Type Optional
name string No
Returns : unknown

{unknown}

Public fireLoaded
fireLoaded()

Fire Loaded event. The event is fired only once, even if fireLoaded() is called multiple times.

Returns : void
Public getApplicationResource
getApplicationResource(key: string, ...properties: string[])

Retrieves a resource with the given key or with the given property path

Paths are just a collection of properties to be identified. Also static fields could be accessed using object instances.

@example let obj = tmp.getApplicationResource('reskey', 'P1', 'P2')

Parameters :
Name Type Optional Description
key string No

the key of the resource

properties string[] No

a collection of property paths

Example :
let obj = tmp.getApplicationResource(&#39;reskey&#39;, &#39;P1&#39;, &#39;P2&#39;)
Returns : any

{any} the resulting data element

GetBindingExpression
GetBindingExpression(dependencyProperty: DependencyProperty)
Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
Returns : any
Public getResourceByKey
getResourceByKey(key: string)

Gets the specific resource by the given key

Parameters :
Name Type Optional
key string No
Returns : unknown

{unknown}

Static HeightChangeCallback
HeightChangeCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

HeightChange Callback Executed when the Height changes

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
Protected initProperties
initProperties()

Initialize the child elements properties of the component in code behind.

Returns : void
Private innerGetChild
innerGetChild(idx: number)

Gets the child number idx from this FrameworkElement.

Parameters :
Name Type Optional
idx number No
Returns : DependencyObject

{DependencyObject}

Private innerGetChildrenCount
innerGetChildrenCount()

Gets the number of children on this FrameworkElement.

Returns : number

{number}

Private innerGetChildrenParent
innerGetChildrenParent(prop: string)

Gets the parent from which children should be taken from.

Parameters :
Name Type Optional
prop string No
Returns : FrameworkElement

{FrameworkElement}

Static IsEnabledCallback
IsEnabledCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

IsEnabled dependency property callback

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
MeasureOverride
MeasureOverride(availableSize: Size)

Measure override method NOTE: We are not supporting this functionality in angular, this implementation is meant only to avoid runtime exceptions, but any code that relies on MeasureOverride should be review and analyze for manual changes

Parameters :
Name Type Optional
availableSize Size No
Returns : Size

{Size}

Public OnApplyTemplate
OnApplyTemplate()

This method is involved in a setTimeout call when a control template is assigned to the current model

Returns : void
Public OnChanges
OnChanges()

Angular Lifecycle Hooks

Returns : void
Protected OnDataContextCallback
OnDataContextCallback(args: DependencyPropertyChangedEventArgs)

Callback action for DataContext property changes

Parameters :
Name Type Optional
args DependencyPropertyChangedEventArgs No
Returns : void
Public OnDestroy
OnDestroy()
Returns : void
Public OnInit
OnInit()

Angular Lifecycle Hook

Returns : void
Public OnIsEnabledChanged
OnIsEnabledChanged(args: DependencyPropertyChangedEventArgs)

On IsEnabled changed handler

Parameters :
Name Type Optional
args DependencyPropertyChangedEventArgs No
Returns : void
OpenCtxMenu
OpenCtxMenu(menu: ContextMenuManager)

Opens an instance of the XamContextMenu This is declared here because it can be set as an attached property and the component should know when it has a XamContextMenu setted to be displayed.

Parameters :
Name Type Optional
menu ContextMenuManager No
Returns : void
Public RaiseSizeChangedEvent
RaiseSizeChangedEvent()

Raise the SizeChanged event

Returns : void
Public RecreateInvalidBindings
RecreateInvalidBindings()

Calling CleanupBindingSubscriptions will set bindingExpression into an invalid state, the expressions and bindings still might persist (if the model is not destroyed), yet the subscriptions were cleaned, if this model is re-bind to a new angular component previous bindings and bindingExpressions will required to be recreated to work properly.

This happens when the angular component is destroyed but the model still persists, like when an *ngIf is used to hide an item in the DOM, yet the model instance still persist until it gets visible again, the binding and bindingExpression will be the same but their subscriptions are gone.

Returns : void
Public refreshBindings
refreshBindings()

Refresh element binding values

Returns : void
Private scheduleFiringSizeChanged
scheduleFiringSizeChanged()

Schedules executing the SizeChanged event

Returns : void
Private setDataContextFromAnchestor
setDataContextFromAnchestor(parent: any)

Sets the datacontext from anchestor when was not directly set to property

Parameters :
Name Type Optional
parent any No
Returns : void
SetTooltipToModel
SetTooltipToModel(tooltip: ToolTipModel)

Set tooltip component

Parameters :
Name Type Optional
tooltip ToolTipModel No
Returns : void
Static StyleCallback
StyleCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

StyleCallback

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
Protected tryApplyStyleFromParentOrDefault
tryApplyStyleFromParentOrDefault()

Tries to apply style from parent or default

Returns : void
UpdateLayout
UpdateLayout()
Inherited from UIElement
Defined in UIElement:541

Updates the layout

Returns : void
Static WidthChangeCallback
WidthChangeCallback(sender: DependencyObject, args: DependencyPropertyChangedEventArgs)

WidthChange Callback Executed when the Width changes

Parameters :
Name Type Optional
sender DependencyObject No
args DependencyPropertyChangedEventArgs No
Returns : void
Public Arrange
Arrange(obj: any)
Inherited from UIElement
Defined in UIElement:393

Arrange method

Parameters :
Name Type Optional
obj any No
Returns : void
Public captureMouse
captureMouse()
Inherited from UIElement
Defined in UIElement:368

Captures the mouse events

Returns : boolean
Public Measure
Measure(obj: any)
Inherited from UIElement
Defined in UIElement:404

Measure method

Parameters :
Name Type Optional
obj any No
Returns : any
Public releaseMouseCapture
releaseMouseCapture()
Inherited from UIElement
Defined in UIElement:379
Returns : void
Protected SyncModelWithComponent
SyncModelWithComponent(params: any)
Inherited from UIElement
Defined in UIElement:409
Parameters :
Name Type Optional Default value
params any No null
Returns : void
Public TransformToVisual
TransformToVisual(obj: UIElement)
Inherited from UIElement
Defined in UIElement:354

Transforms to visual

Parameters :
Name Type Optional
obj UIElement No
Returns : any
Public withName
withName(name: string)
Inherited from UIElement
Defined in UIElement:341
Parameters :
Name Type Optional
name string No
Returns : UIElement
Private addRelatedSubscriptionIfRequired
addRelatedSubscriptionIfRequired(event: SubscriptionEvent<any>, theHandler: any, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
event SubscriptionEvent<any> No
theHandler any No
bindingExpression BindingExpression No
Returns : void
Private addSubscriptionForTwoWayBindings
addSubscriptionForTwoWayBindings(dependencyProperty: DependencyProperty, binding: Binding, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding Binding No
bindingExpression BindingExpression No
Returns : void
addsValidationMessage
addsValidationMessage(propKey: Binding | string, message: string)
Inherited from DependencyObject

Adds a new validation message associated to a binding or a property name

Parameters :
Name Type Optional
propKey Binding | string No
message string No
Returns : void
Private beginSubscribeToMultiPropertyPathChanges
beginSubscribeToMultiPropertyPathChanges(context: any, binding: Binding, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
context any No
binding Binding No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
Returns : void
Private checkForSubscriptoinToDataErrorInfo
checkForSubscriptoinToDataErrorInfo(currentContext: any, binding: Binding, propertyToSubscribe: string, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
binding Binding No
propertyToSubscribe string No
bindingExpression BindingExpression No
Returns : void
Public clearValue
clearValue(property: DependencyProperty)
Inherited from DependencyObject

Clears the dependency property value

Parameters :
Name Type Optional
property DependencyProperty No
Returns : void
Equals
Equals(obj: any)
Inherited from DependencyObject

Compares this dependency object agains another object.

Parameters :
Name Type Optional
obj any No
Returns : boolean

{boolean}

GetChild
GetChild(idx: number)
Inherited from DependencyObject

Gets the child element at the index position

Parameters :
Name Type Optional
idx number No
Returns : DependencyObject

{DependencyObject}

GetChildrenCount
GetChildrenCount()
Inherited from DependencyObject

Method o know the amount of children the parent has

Returns : number

{number}

GetHashCode
GetHashCode()
Inherited from DependencyObject

Gets a hash code for this dependency object.

Returns : number

{number}

Public getValue
getValue(property: DependencyProperty)
Inherited from DependencyObject

Gets the value of a dependency property

Parameters :
Name Type Optional
property DependencyProperty No
Returns : any
Private handleErrorsOnContext
handleErrorsOnContext(errorCtxt: INotifyDataErrorInfo, args: DataErrorsChangedEventArgs)
Inherited from DependencyObject

Check and register possible errors in an error context

Parameters :
Name Type Optional
errorCtxt INotifyDataErrorInfo No
args DataErrorsChangedEventArgs No
Returns : void
Public IsPropertySet
IsPropertySet(propertyName: string)
Inherited from DependencyObject

Indicates if the property has been already set.

Parameters :
Name Type Optional
propertyName string No
Returns : any
Private performDataErrorValidationIfRequired
performDataErrorValidationIfRequired(binding: Binding, theBindingContext: any)
Inherited from DependencyObject

Performs validation on model if the model implementes IDataErrorINfo

Parameters :
Name Type Optional
binding Binding No
theBindingContext any No
Returns : void
Private performRemoveValidationIfInValidationError
performRemoveValidationIfInValidationError(binding: Binding)
Inherited from DependencyObject

Performs the remove validation if the InValidationError is true

Parameters :
Name Type Optional
binding Binding No
Returns : void
Public performTargetObjectBindingUpdate
performTargetObjectBindingUpdate(dependencyProperty: DependencyProperty, binding: Binding)
Inherited from DependencyObject

Updates the target object value associated to the binding.

Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding Binding No
Returns : void
Private preprocessValue
preprocessValue(property: DependencyProperty, value: any)
Inherited from DependencyObject

Preprocess value to be set to dependency property

Parameters :
Name Type Optional
property DependencyProperty No
value any No
Returns : any
Private recreateSubscriptionsForMultiPropertyBindingPath
recreateSubscriptionsForMultiPropertyBindingPath(currentContext: any, outerContext: any, properties: string[], propertyIndex: number, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression, subscriptionsForCurrentBindingPath: Array<>)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
outerContext any No
properties string[] No
propertyIndex number No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
subscriptionsForCurrentBindingPath Array<> No
Returns : void
Private registerSetPropertyIfRequired
registerSetPropertyIfRequired(name: string)
Inherited from DependencyObject

Register set property if required

Parameters :
Name Type Optional
name string No
Returns : void
Private removeSubscriptionsForMultiPropertyBindingPath
removeSubscriptionsForMultiPropertyBindingPath(subscriptionsForCurrentBindingPath: [], propertyIndex: number)
Inherited from DependencyObject
Parameters :
Name Type Optional
subscriptionsForCurrentBindingPath [] No
propertyIndex number No
Returns : void
removeValidationMessage
removeValidationMessage(propKey: Binding | string)
Inherited from DependencyObject

Removes a validation message associated to a binding or a property name

Parameters :
Name Type Optional
propKey Binding | string No
Returns : void
SetBinding
SetBinding(dependencyProperty: DependencyProperty, binding: Binding)
Inherited from DependencyObject

Sets a binding to the specified property at runtime

Parameters :
Name Type Optional Description
dependencyProperty DependencyProperty No

property to bind

binding Binding No

binding object

Returns : void
Public setValue
setValue(property: DependencyProperty, value: any)
Inherited from DependencyObject

Sets the value for a dependency property

Parameters :
Name Type Optional
property DependencyProperty No
value any No
Returns : void
Public setValueForScopedRegion
setValueForScopedRegion(property: DependencyProperty, value: any, scopedRegionManager: IRegionManager)
Inherited from DependencyObject

Sets the value for a dependency property. This is a workaround to support Scoped Region Managers. A research is required to find out the way to get the application region Manager when scoped region managers are used (when creating the DelayedRegionBehavior, the correct scoped region manager must be passed as an argument).

Parameters :
Name Type Optional
property DependencyProperty No
value any No
scopedRegionManager IRegionManager No
Returns : void
Protected shouldPreventDefaultSourceUpdate
shouldPreventDefaultSourceUpdate(dependencyProperty: DependencyProperty, binding: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
dependencyProperty DependencyProperty No
binding BindingExpression No
Returns : boolean
Private subscribeToBindingPathChanges
subscribeToBindingPathChanges(context: any, binding: Binding, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
context any No
binding Binding No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
Returns : void
Private subscribeToErrorsChangedInModel
subscribeToErrorsChangedInModel(errorCtxt: INotifyDataErrorInfo, propertyToSubscribe: string, bindingExpression: BindingExpression)
Inherited from DependencyObject
Parameters :
Name Type Optional
errorCtxt INotifyDataErrorInfo No
propertyToSubscribe string No
bindingExpression BindingExpression No
Returns : void
Private subscribeToPropertyChanges
subscribeToPropertyChanges(currentContext: any, outerContext: any, properties: string[], propertyIndex: number, dependencyProperty: DependencyProperty, bindingExpression: BindingExpression, subscriptionsForCurrentBindingPath: Array<>)
Inherited from DependencyObject
Parameters :
Name Type Optional
currentContext any No
outerContext any No
properties string[] No
propertyIndex number No
dependencyProperty DependencyProperty No
bindingExpression BindingExpression No
subscriptionsForCurrentBindingPath Array<> No
Returns : void
Private updateSourceOfBinding
updateSourceOfBinding(binding: Binding, outerContext: any, dependencyProperty: DependencyProperty)
Inherited from DependencyObject

Updates the source of a binding

Parameters :
Name Type Optional
binding Binding No
outerContext any No
dependencyProperty DependencyProperty No
Returns : void

Accessors

Height
getHeight()
setHeight(value: number)

Gets or sets the height

Parameters :
Name Type Optional
value number No
Returns : void
DataContext
getDataContext()

Gets or sets the dataContext for this model

Returns : any
setDataContext(value: any)
Parameters :
Name Type Optional
value any No
Returns : void
IsFirstTimeLoad
getIsFirstTimeLoad()

Checks if the model is being loaded for the first time.

Returns : boolean
setIsFirstTimeLoad(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
Parent
getParent()

Parent model for this model

Returns : FrameworkElement
setParent(value: FrameworkElement)
Parameters :
Name Type Optional
value FrameworkElement No
Returns : void
import { Cursor } from '../baseframework/Cursor';
import {
  HorizontalAlignment,
  VerticalAlignment,
} from '../models/controls/ContainerEnums';
import { ContextMenuManager } from '../models/controls/ContextMenuManager';
import { Size, SizeChangedEventArgs } from '../models/controls/Size';
import { ThicknessModel } from '../models/controls/ThicknessModel';
import { ToolTipModel } from '../models/controls/ToolTipModel';
import { SubscriptionEvent } from '../utils/SubscriptionEvent';
import { setSingleTimeoutForCurrentEventHandler } from '../utils/TimeoutHelper';
import { Application } from './Application';
import { Dependency } from './Dependency';
import { DependencyObject } from './DependencyObject';
import { DependencyProperty } from './DependencyProperty';
import { DependencyPropertyChangedEventArgs } from './DependencyPropertyChangedEventArgs';
import { ResourceDictionary } from './ResourceDictionary';
import { RuntimeStyleInfo } from './RuntimeStyleInfo';
import { UIElement } from './UIElement';

/**
 * Framework element model
 *
 * @export
 * @class FrameworkElement
 * @extends {UIElement}
 * @wType System.Windows.FrameworkElement
 */
export class FrameworkElement extends UIElement {
  /**
   * ActualHeightProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static ActualHeightProperty: DependencyProperty = new DependencyProperty(
    'ActualHeight',
    0,
    null
  );

  /**
   * ActualWidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static ActualWidthProperty: DependencyProperty = new DependencyProperty(
    'ActualWidth',
    0,
    null
  );

  /**
   * CursorProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static CursorProperty: DependencyProperty = new DependencyProperty(
    'Cursor',
    null,
    null
  );

  /**
   * DataContextProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static DataContextProperty: DependencyProperty = new DependencyProperty(
    'DataContext',
    null,
    FrameworkElement.DataContextCallback
  );

  /**
   * FlowDirectionProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static FlowDirectionProperty: DependencyProperty = new DependencyProperty(
    'FlowDirection',
    null,
    null
  );

  /**
   * HeightProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static readonly HeightProperty = new DependencyProperty(
    'Height',
    Number.NaN,
    FrameworkElement.HeightChangeCallback
  );

  /**
   * HorizontalAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static HorizontalAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'HorizontalAlignment',
      HorizontalAlignment.Stretch,
      null
    );

  /**
   * HorizontalContentAlignment dependency property.
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static readonly HorizontalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'HorizontalContentAlignment',
      HorizontalAlignment.Center,
      null
    );

  /**
   * IsEnabledProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   * @wIgnore
   */
  static readonly IsEnabledProperty = new DependencyProperty(
    'IsEnabled',
    true,
    FrameworkElement.IsEnabledCallback
  );

  /**
   * LanguageProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static LanguageProperty: DependencyProperty = new DependencyProperty(
    'Language',
    null,
    null
  );

  /**
   * MarginProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static MarginProperty: DependencyProperty = new DependencyProperty(
    'Margin',
    null,
    null
  );

  /**
   * MaxHeightProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static MaxHeightProperty: DependencyProperty = new DependencyProperty(
    'MaxHeight',
    0,
    null
  );

  /**
   * MaxWidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static MaxWidthProperty: DependencyProperty = new DependencyProperty(
    'MaxWidth',
    0,
    null
  );

  /**
   * MinHeightProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static MinHeightProperty: DependencyProperty = new DependencyProperty(
    'MinHeight',
    0,
    null
  );

  /**
   * MinWidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static MinWidthProperty: DependencyProperty = new DependencyProperty(
    'MinWidth',
    0,
    null
  );

  /**
   * NameProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static NameProperty: DependencyProperty = new DependencyProperty(
    'Name',
    null,
    null
  );

  /**
   * StyleProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static StyleProperty: DependencyProperty = new DependencyProperty(
    'Style',
    null,
    FrameworkElement.StyleCallback
  );

  /**
   * TagProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static TagProperty = new DependencyProperty('Tag', null, null);

  /**
   * VerticalAlignmentProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static VerticalAlignmentProperty: DependencyProperty = new DependencyProperty(
    'VerticalAlignment',
    VerticalAlignment.Stretch,
    null
  );

  /**
   * VerticalContentAlignment dependency property.
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   */
  static VerticalContentAlignmentProperty: DependencyProperty =
    new DependencyProperty(
      'VerticalContentAlignment',
      VerticalAlignment.Center,
      null
    );

  /**
   * WidthProperty dependency property
   *
   * @static
   * @type {DependencyProperty}
   * @memberof FrameworkElement
   * @wProperty WidthProperty
   */
  static WidthProperty: DependencyProperty = new DependencyProperty(
    'Width',
    Number.NaN,
    FrameworkElement.WidthChangeCallback
  );

  private currentStyleChange: string[];
  private sizeChangedPendingTimeout: any;

  /**
   * StyleCallback
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public static StyleCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    const newStyle = args.NewValue;
    const frmElement = sender as FrameworkElement;

    if (frmElement == null) {
      return;
    }

    if (args.OldValue != null) {
      for (const s of frmElement.currentStyleChange) {
        if (!frmElement.IsPropertySet(s)) {
          delete frmElement.properties[s];
        }
      }
    }
    frmElement.currentStyleChange = [];
    if (newStyle instanceof RuntimeStyleInfo) {
      for (const setter of newStyle.Setters) {
        frmElement.isEnableSetPropertiesRegistry = false;
        let propertyName = setter.resolvePropertyName();
        if (
          !frmElement.IsPropertySet(propertyName) &&
          setter.Apply(frmElement)
        ) {
          frmElement.currentStyleChange.push(propertyName);
        }
        frmElement.isEnableSetPropertiesRegistry = true;
      }
    }
    frmElement.isDefaultStyleApplied = false;
  }

  /**
   * HeightChange Callback
   * Executed when the Height changes
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public static HeightChangeCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    const ctx = sender as any;
    if (ctx.ActualHeight !== args.NewValue) {
      ctx.scheduleFiringSizeChanged();
    }
  }

  /**
   * WidthChange Callback
   * Executed when the Width changes
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public static WidthChangeCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    const ctx = sender as any;
    if (ctx.ActualWidth !== args.NewValue) {
      ctx.scheduleFiringSizeChanged();
    }
    if (args.NewValue < 0) {
      ctx.Width = 0;
    }
  }

  /**
   * DataContext Callback
   * Executed when the Width changes
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public static DataContextCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    if (sender instanceof FrameworkElement) {
      sender.OnDataContextCallback(args);
    }
  }

  /**
   * IsEnabled dependency property callback
   *
   * @static
   * @param {DependencyObject} sender
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public static IsEnabledCallback(
    sender: DependencyObject,
    args: DependencyPropertyChangedEventArgs
  ) {
    if (sender instanceof FrameworkElement) {
      sender.OnIsEnabledChanged(args);
    }
  }
  /**
   * On IsEnabled changed handler
   *
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  public OnIsEnabledChanged(args: DependencyPropertyChangedEventArgs) {}

  /**
   * Angular Lifecycle Hook
   *
   * @memberof FrameworkElement
   */
  public OnInit(): void {
    /* OnInit Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hook
   *
   * @memberof FrameworkElement
   */
  public AfterContentInit(): void {
    /* AfterContentInit Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hooks
   *
   * @memberof FrameworkElement
   */
  public OnChanges(): void {
    /* OnChanges Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hooks
   *
   * @memberof FrameworkElement
   */
  public DoCheck(): void {
    /* DoCheck Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hooks
   *
   * @memberof FrameworkElement
   */
  public AfterContentChecked(): void {
    /* AfterContentChecked Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hooks
   *
   * @memberof FrameworkElement
   */
  public AfterViewChecked(): void {
    /* AfterViewChecked Angular Lifecycle hook */
  }

  /*
   * Angular Lifecycle Hook
   *
   * @memberof FrameworkElement
   */
  public OnDestroy(): void {
    /* OnDestroy Angular Lifecycle hook */
  }

  /**
   * Angular Lifecycle Hook.
   * According to SL Documentation
   * LayoutUpdated is the last object lifetime event to occur in the sequence before a control is ready for interaction.
   * A setTimeout is set to ensure that it is triggered after everything is resolved.
   *
   * @memberof FrameworkElement
   */
  public AfterViewInit(): void {
    this.fireLoaded();
    setTimeout(() => {
      this.LayoutUpdated.fire([this, null]);
      this.MeasureOverride(new Size(Infinity, Infinity));
    }, 100);
  }

  /**
   * Updates the layout
   *
   * @memberof FrameworkElement
   * @wMethod UpdateLayout
   * @wIgnore
   */
  UpdateLayout(): void {
    super.UpdateLayout();
    this.LayoutUpdated.fire([this, null]);
  }

  /**
   * Opens an instance of the XamContextMenu
   * This is declared here because it can be set as an attached property
   * and the component should know when it has a XamContextMenu setted to be displayed.
   *
   * @param {ContextMenuManager} menu
   * @memberof FrameworkElement
   * @wIgnore
   */
  OpenCtxMenu(menu: ContextMenuManager): void {
    this.ctxMenuManager = menu;
    this.CtxMenuOpened.fire([this, menu]);
  }

  /**
   * Set tooltip component
   *
   * @param {ToolTipModel} tooltip
   * @memberof FrameworkElement
   * @wIgnore
   */
  SetTooltipToModel(tooltip: ToolTipModel): void {
    this.tooltip = tooltip;
    this.ToolTipSet.fire([this, tooltip]);
  }

  /**
   * Measure override method
   * NOTE:
   *      We are not supporting this functionality in angular, this implementation is meant only to avoid runtime exceptions, but any code
   *      that relies on MeasureOverride should be review and analyze for manual changes
   *
   * @param {Size} availableSize
   * @return {*}  {Size}
   * @memberof FrameworkElement
   */
  MeasureOverride(availableSize: Size): Size {
    return new Size(
      availableSize?.Width ?? Infinity,
      availableSize?.Height ?? Infinity
    );
  }

  public Loaded: SubscriptionEvent<(s: any, a: any) => void> =
    new SubscriptionEvent();
  public Unloaded: SubscriptionEvent<(s: any, a: any) => void> =
    new SubscriptionEvent();
  public LayoutUpdated: SubscriptionEvent<(sender: any, e: any) => void> =
    new SubscriptionEvent();

  /**
   * Context menu opened event
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  public CtxMenuOpened: SubscriptionEvent<(sender: any, e: any) => void> =
    new SubscriptionEvent();

  /**
   * ToolTipSet event
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  public ToolTipSet: SubscriptionEvent<(sender: any, e: any) => void> =
    new SubscriptionEvent();

  public SizeChanged: SubscriptionEvent<
    (s: any, a: SizeChangedEventArgs) => void
  > = new SubscriptionEvent();
  public name = '';
  /**
   * Flag to determine if the framework element has the docus
   *
   * @type {boolean}
   * @memberof FrameworkElement
   */
  public hasFocus = false;

  /**
   * Gets value indicating if the control is enabled
   *
   * @type {boolean}
   * @memberof FrameworkElement
   * @wNoMap
   * /// TODO check property defined in Control instead of framework element
   */
  @Dependency(FrameworkElement.IsEnabledProperty)
  public IsEnabled: boolean;

  /**
   * Gets or sets the margin
   *
   * @type {ThicknessModel}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.MarginProperty)
  public Margin: ThicknessModel;
  /**
   * Gets or sets the cursor
   *
   * @type {*}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.CursorProperty)
  public Cursor: Cursor;
  /**
   * Gets or sets the clip
   *
   * @type {*}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.ClipProperty)
  public Clip: any;
  /**
   * Gets or sets the flow direction
   *
   * @type {*}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.FlowDirectionProperty)
  public FlowDirection: any;

  /**
   * Gets or sets the max width
   *
   * @type {number}
   * @memberof FrameworkElement
   * @wProperty MaxWidth
   */
  @Dependency(FrameworkElement.MaxWidthProperty)
  public maxWidth: number;

  /**
   * Gets or sets the min width
   *
   * @type {number}
   * @memberof FrameworkElement
   * @wProperty MinWidth
   */
  @Dependency(FrameworkElement.MinWidthProperty)
  public minWidth: number;

  /**
   * Gets or sets the min height
   *
   * @type {number}
   * @memberof FrameworkElement
   * @wProperty MinHeight
   */
  @Dependency(FrameworkElement.MinHeightProperty)
  public minHeight: number;

  /**
   * Gets or sets max height
   *
   * @type {number}
   * @memberof FrameworkElement
   * @wProperty MaxHeight
   */
  @Dependency(FrameworkElement.MaxHeightProperty)
  public maxHeight: number;

  /**
   * Resources property
   *
   * @type {ResourceDictionary}
   * @memberof FrameworkElement
   * @wProperty Resources
   */
  public resources: ResourceDictionary = new ResourceDictionary();

  /**
   * Instance related to a XamContextMenuComponent
   *
   * @type {ContextMenuManager}
   * @memberof FrameworkElement
   */
  public ctxMenuManager: ContextMenuManager;

  /**
   * Instance related to a tooltip component
   * for this control
   *
   * @type {ToolTipModel}
   * @memberof FrameworkElement
   */
  public tooltip: ToolTipModel = null;

  private parent: FrameworkElement = null;

  #allowDataContextAnchestorSet = true;

  /**
   * Reference to a callback function called whenever the parent have changed.
   *
   * @type {void}
   * @memberof FrameworkElement
   */
  #parentChangeHandler: (prop: string) => void;

  /**
   * Gets or sets the horizontal alignment
   *
   * @type {HorizontalAlignment}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.HorizontalAlignmentProperty)
  public HorizontalAlignment: HorizontalAlignment;

  /**
   * Gets or sets the horizontal content alignment.
   *
   * @type {HorizontalAlignment}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.HorizontalContentAlignmentProperty)
  public HorizontalContentAlignment: HorizontalAlignment;

  /**
   * Gets or sets the vertical alignment
   *
   * @type {VerticalAlignment}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.VerticalAlignmentProperty)
  public VerticalAlignment: VerticalAlignment;

  /**
   * Gets or sets the vertical content alignment.
   *
   * @type {VerticalAlignment}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.VerticalContentAlignmentProperty)
  public VerticalContentAlignment: VerticalAlignment;

  /**
   * Gets or sets the width
   *
   * @return {*}  {number}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.WidthProperty)
  public Width: number;

  /**
   * Gets or sets the style
   *
   * @type {RuntimeStyleInfo}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.StyleProperty)
  public Style: RuntimeStyleInfo;

  #height: number;
  /**
   * Gets or sets the height
   *
   * @return {*}  {number}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.HeightProperty)
  set Height(value: number) {
    this.#height = value;
  }

  get Height(): number {
    return this.#height;
  }

  /**
   * Flag used to check if it is the first time loading a model or not.
   *
   * @type {boolean}
   * @memberof FrameworkElement
   */
  private isFirstTimeLoad = true;

  /**
   * Gets or sets the dataContext for this model
   *
   * @type {*}
   * @memberof FrameworkElement
   */
  public get DataContext(): any {
    (this.Parent as any)?.refreshDataContext?.();
    return this.getValue(FrameworkElement.DataContextProperty);
  }

  public set DataContext(value: any) {
    this.setValue(FrameworkElement.DataContextProperty, value);
  }

  /**
   * Checks if the model is being loaded for the first time.
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  get IsFirstTimeLoad(): boolean {
    return this.isFirstTimeLoad;
  }

  /**
   *
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  set IsFirstTimeLoad(value: boolean) {
    this.isFirstTimeLoad = value;
  }

  /**
   * Parent model for this model
   *
   * @type {FrameworkElement}
   * @memberof FrameworkElement
   */
  public get Parent(): FrameworkElement {
    return this.parent;
  }
  public set Parent(value: FrameworkElement) {
    if (this.parent !== value) {
      if (this.parent && this.#parentChangeHandler) {
        this.parent.change.removeHandler(this.#parentChangeHandler);
        if (value === null) {
          this.setDataContextFromAnchestor(null);
        }
      }
      this.#parentChangeHandler = null;
      this.parent = value;
      this.change.fire(['Parent']);
      if (this.parent) {
        this.tryApplyStyleFromParentOrDefault();
        this.setDataContextFromAnchestor(this.parent);
        this.#parentChangeHandler = (prop: string) => {
          if (prop == 'DataContext') {
            this.setDataContextFromAnchestor(this.parent);
          }
          this.change.fire(['Parent']);
        };
        value.change.addHandler(this.#parentChangeHandler);
      }
    }
  }

  /**
   * Gets or sets the tag
   *
   * @type {*}
   * @memberof FrameworkElement
   */
  @Dependency(FrameworkElement.TagProperty)
  public Tag: any;

  @Dependency(FrameworkElement.ActualHeightProperty)
  public ActualHeight: number;

  @Dependency(FrameworkElement.ActualWidthProperty)
  public ActualWidth: number;

  /**
   * Indicates if the current style is from a default style
   *
   * @protected
   * @type {boolean}
   * @memberof FrameworkElement
   */
  protected isDefaultStyleApplied: boolean;

  GetBindingExpression(dependencyProperty: DependencyProperty): any {
    return this.bindingExpressions.getItem(dependencyProperty.name);
  }

  /**
   * Find an object by its `Name`.
   *
   * @param {string} name
   * @return {*}  {unknown}
   * @memberof FrameworkElement
   */
  public FindName(name: string): unknown {
    if (this.Name === name) {
      return this;
    }
    const count = this.innerGetChildrenCount();
    for (let i = 0; i < count; i++) {
      const child = this.innerGetChild(i);
      if (child && child['Name'] === name) {
        // eslint-disable-line @typescript-eslint/dot-notation
        return child;
      }
      const found =
        child instanceof FrameworkElement ? child.FindName(name) : null;
      if (found) {
        return found;
      }
    }
    return null;
  }

  /**
   * Refresh element binding values
   *
   * @memberof FrameworkElement
   */
  public refreshBindings(): void {}

  /**
   * This method is involved in a `setTimeout` call when a control template is assigned
   * to the current model
   *
   * @memberof FrameworkElement
   */
  public OnApplyTemplate() {}

  /**
   * Clean up any subscription created for user bindings
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  public CleanupBindingSubscriptions(): void {
    if (this.bindingExpressions && this.bindingExpressions.count > 0) {
      for (const pairs of this.bindingExpressions) {
        pairs[1].CleanupSubscriptions();
      }
    }
  }

  /**
   * Calling CleanupBindingSubscriptions will set bindingExpression into an invalid state, the expressions
   * and bindings still might persist (if the model is not destroyed), yet the subscriptions were cleaned,
   * if this model is re-bind to a new angular component previous bindings and bindingExpressions will required
   * to be recreated to work properly.
   *
   * This happens when the angular component is destroyed but the model still persists, like when an *ngIf is
   * used to hide an item in the DOM, yet the model instance still persist until it gets visible again, the binding
   * and bindingExpression will be the same but their subscriptions are gone.
   *
   * @memberof FrameworkElement
   * @wIgnore
   */
  public RecreateInvalidBindings(): void {
    const bindingExpressions = [...this.bindingExpressions];
    for (const pairs of bindingExpressions) {
      if (pairs[1].InInvalidState) {
        if (pairs[1].Property && pairs[1].ParentBinding) {
          const oldInitializationFlagValue = this.IsInitializingBindings;
          try {
            this.IsInitializingBindings = true;
            this.SetBinding(pairs[1].Property, pairs[1].ParentBinding);
          } finally {
            this.IsInitializingBindings = oldInitializationFlagValue;
          }
        } else {
          console.error(
            'BindingExpression needs to be recreated but some info is missing'
          );
        }
      }
    }
  }

  /**
   *  Retrieves a resource with the given key or with the given property path
   *
   *  Paths are just a collection of properties to be identified. Also static
   *  fields could be accessed using object instances.
   *
   *  @example
   *  let obj = tmp.getApplicationResource('reskey', 'P1', 'P2')
   *
   * @param {string} key the key of the resource
   * @param {...string[]} properties  a collection of property paths
   * @return {*}  {any} the resulting data element
   * @memberof FrameworkElement
   */
  public getApplicationResource(key: string, ...properties: string[]): any {
    let result = this.getResourceByKey(key);
    if (result && properties && properties.length > 0) {
      // eslint-disable-next-line @typescript-eslint/prefer-for-of
      for (let i = 0; i < properties.length; i++) {
        if (result && typeof result[properties[i]] !== 'undefined') {
          // In this case the path fragment refers to an instance field or property
          result = result[properties[i]];
        } else if (
          result &&
          result.constructor &&
          typeof result.constructor[properties[i]] !== 'undefined'
        ) {
          // In this case the path fragment is referenting to a static field or property
          result = result.constructor[properties[i]];
        } else {
          result = null;
          break;
        }
      }
    }
    return result;
  }

  /**
   *  Gets the specific resource by the given key
   *
   * @param {string} key
   * @return {*}  {unknown}
   * @memberof FrameworkElement
   */
  public getResourceByKey(key: string): unknown {
    let resource =
      this.resources?.Get(key) ?? this.Parent?.getResourceByKey(key);
    if (!resource && Application.Current) {
      resource = Application.Current.getResourceByKey(key);
    }
    return resource;
  }

  /**
   * Fire `Loaded` event. The event is fired only once, even if `fireLoaded()`
   * is called multiple times.
   *
   * @memberof FrameworkElement
   */
  public fireLoaded(): void {
    if (this.isFirstTimeLoad) {
      this.Loaded.fire([this, null]);
      this.isFirstTimeLoad = false;
    }
  }

  /**
   *  Raise the `SizeChanged` event
   *
   * @memberof BaseComponent
   * @wIgnore
   */
  public RaiseSizeChangedEvent() {
    const argsEv = new SizeChangedEventArgs();
    argsEv.PreviousSize = this.RenderSize;
    const newSize = new Size(this.ActualWidth, this.ActualHeight);
    this.RenderSize = newSize;
    argsEv.NewSize = newSize;
    this.SizeChanged.fire([this, argsEv]);
  }

  /**
   * Callback action for DataContext property changes
   *
   * @protected
   * @param {DependencyPropertyChangedEventArgs} args
   * @memberof FrameworkElement
   * @wIgnore
   */
  protected OnDataContextCallback(args: DependencyPropertyChangedEventArgs) {
    this.#allowDataContextAnchestorSet = false;
  }

  /**
   * Initialize the child elements properties of the component in code behind.
   *
   * @protected
   * @memberof FrameworkElement
   */
  protected initProperties() {}

  /**
   * Tries to apply style from parent or default
   *
   * @protected
   * @memberof FrameworkElement
   */
  protected tryApplyStyleFromParentOrDefault(): void {
    if (this.Style == null || this.isDefaultStyleApplied) {
      var style = this.getResourceByKey(
        '__DEFAULT_STYLE__' + this.constructor.name.replace(/Model$/, '')
      );
      this.Style = style instanceof RuntimeStyleInfo ? style : null;
      this.isDefaultStyleApplied = this.Style ? true : false;
    }
  }

  /**
   * Sets the datacontext from anchestor when was not directly set to property
   *
   * @private
   * @param {*} dataContext
   * @memberof FrameworkElement
   */
  private setDataContextFromAnchestor(parent: any) {
    if (this.#allowDataContextAnchestorSet) {
      this.DataContext = parent?.DataContext;
      this.#allowDataContextAnchestorSet = true;
    }
  }

  /**
   * Gets the child number `idx` from this `FrameworkElement`.
   *
   * @private
   * @param {number} idx
   * @return {*}  {DependencyObject}
   * @memberof FrameworkElement
   */
  private innerGetChild(idx: number): DependencyObject {
    const parent = this.innerGetChildrenParent('GetChild');
    return parent.GetChild(idx);
  }

  /**
   * Gets the number of children on this `FrameworkElement`.
   *
   * @private
   * @return {*}  {number}
   * @memberof FrameworkElement
   */
  private innerGetChildrenCount(): number {
    const parent = this.innerGetChildrenParent('GetChildrenCount');
    return parent.GetChildrenCount();
  }

  /**
   * Gets the parent from which children should be taken from.
   *
   * @private
   * @param {string} prop
   * @return {*}  {FrameworkElement}
   * @memberof FrameworkElement
   */
  private innerGetChildrenParent(prop: string): FrameworkElement {
    /* eslint-disable @typescript-eslint/dot-notation */
    return this['templateModel'] && this['templateModel'][prop]
      ? this['templateModel']
      : this;
  }

  /**
   * Schedules executing the SizeChanged event
   *
   * @private
   * @memberof FrameworkElement
   */
  private scheduleFiringSizeChanged() {
    if (this.sizeChangedPendingTimeout == null) {
      this.sizeChangedPendingTimeout = setSingleTimeoutForCurrentEventHandler(
        () => {
          if (!isNaN(this.Width)) {
            this.ActualWidth = this.Width;
          }
          if (!isNaN(this.Height)) {
            this.ActualHeight = this.Height;
          }
          this.change.fire(['calculateActualSize']);
          this.RaiseSizeChangedEvent();
          this.sizeChangedPendingTimeout = null;
        }
      );
    }
  }
}

result-matching ""

    No results matching ""