Class NavBar

Displays navigation commands in a toolbar that the user can show or hide.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(element?: HTMLElement, options?: any): NavBar

Creates a new NavBar.

constructor

Parameters

  • element?: HTMLElement optional

    The DOM element that will host the new NavBar.

  • options?: any optional

    An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events.

Returns

NavBar

Properties

public commands: AppBarCommand

This API supports the WinJS infrastructure and is not intended to be used directly from your code.

public disabled: boolean

Gets or sets a value that indicates whether the NavBar is disabled.

public element: HTMLElement

Gets the HTML element that hosts this NavBar.

public hidden: boolean

Gets a value that indicates whether the NavBar is hidden or in the process of becoming hidden.

public layout: string

This API supports the WinJS infrastructure and is not intended to be used directly from your code.

public placement: string

Gets or sets a value that specifies whether the NavBar appears at the top or bottom of the main view.

public sticky: boolean

Gets or sets a value that indicates whether the NavBar is sticky (won't light dismiss). If not sticky, the NavBar dismisses normally when the user touches outside of the NavBar.

Methods

public addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean)

Registers an event handler for the specified event.

Parameters

  • eventName: string

    The name of the event to handle. Note that you drop the "on" when specifying the event name. For example, instead of specifying "onclick", you specify "click".

  • eventHandler: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispatchEvent(type: string, eventProperties: any): boolean

Raises an event of the specified type and with additional properties.

Parameters

  • type: string

    The type (name) of the event.

  • eventProperties: any

    The set of additional properties to be attached to the event object when the event is raised.

Returns

boolean

true if preventDefault was called on the event, otherwise false.

public dispose()

Releases resources held by this NavBar. Call this method when the NavBar is no longer needed. After calling this method, the NavBar becomes unusable.

public hide()

Hides the NavBar.

public hideCommands(commands: Array<any>, immediate: boolean)

Hides the specified commands of the NavBar.

Parameters

  • commands: Array<any>

    The commands to hide. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false.

public onafterhide(eventInfo: Event)

Occurs immediately after the NavBar is hidden.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onaftershow(eventInfo: Event)

Raised after the NavBar is shown.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onbeforehide(eventInfo: Event)

Raised just before the NavBar is hidden.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onbeforeshow(eventInfo: Event)

Occurs before a hidden NavBar is shown.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onchildrenprocessed(eventInfo: Event)

Occurs after the NavBar has finished processing its child elements.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • eventName: string

    The name of the event that the event handler is registered for.

  • eventCallback: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.

public show()

Shows the NavBar if it is not disabled.

public showCommands(commands: Array<any>, immediate: boolean)

Shows the specified commands of the NavBar.

Parameters

  • commands: Array<any>

    The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false.

public showOnlyCommands(commands: Array<any>, immediate: boolean)

Shows the specified commands of the NavBar while hiding all other commands.

Parameters

  • commands: Array<any>

    The commands to show. The array elements may be NavBarCommand objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false.