Compartir a través de


WinJS.UI.NavBarCommand object

[NavBarCommand is no longer available for use as of Windows Library for JavaScript (WinJS) 4.2. Instead, use SplitViewCommand. ]

A command to be displayed in a NavBarContainer of a navigation app bar (top app bar).

Explore this functionality in more depth as part of our App features, start to finish series: Flat navigation, start to finish (HTML) and Hierarchical navigation, start to finish (HTML)

Syntax

<div 
    data-win-control="WinJS.UI.NavBarCommand">
</div>
var object = new WinJS.UI.NavBarCommand();

Members

The NavBarCommand object has these types of members:

  • Constructors
  • Methods
  • Properties

Constructors

The NavBarCommand object has these constructors.

Constructor Description
NavBarCommand

Creates a new NavBarCommand object.

 

Methods

The NavBarCommand object has these methods.

Method Description
addEventListener

Registers an event handler for the specified event.

dispatchEvent

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

dispose

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

removeEventListener

Removes an event handler registered with addEventListener.

 

Properties

The NavBarCommand object has these properties.

Property Access type Description

element

Read/write

Gets the DOM element that hosts the NavBarCommand.

icon

Read/write

Gets or sets the NavBarCommand icon.

label

Read/write

Gets or sets the NavBarCommand label.

location

Read/write

Get or sets the page to navigate to when this command is invoked.

splitButton

Read/write

Gets or sets a value that specifies whether the NavBarCommand can contain child commands.

splitOpened

Read-only

Gets a value that indicates whether the splitButton is open.

state

Read/write

Gets or sets a user-defined object that represents the state associated with the command's location.

tooltip

Read/write

Gets or sets the tooltip of the NavBarCommand.

 

Remarks

CSS classes

To customize the NavBarCommand, you can define your own styles for these Cascading Style Sheets (CSS) classes (defined by the Windows Library for JavaScript style sheets):

CSS class Description

win-navbarcommand

Styles the entire NavBarCommand.

win-navbarcommand-button

Styles the button portion of the NavBarCommand.

win-navbarcommand-icon

Styles the NavBarCommand object's icon box.

win-navbarcommand-icononly

Styles entire NavBarCommand when it contains an icon but no label.

win-navbarcommand-label

Styles the label of a NavBarCommand.

win-navbarcommand-labelonly

Styles the entire NavBarCommand when it contains a label but no icon.

win-navbarcommand-splitbutton

Styles the split button of a NavBarCommand.

win-navbarcommand-splitbutton-opened

Styles the split button of a NavBarCommand when the split button is open.

 

Requirements

Minimum WinJS version

WinJS 2.0

Namespace

WinJS.UI

See also

WinJS.UI Namespace

NavBar

NavBarContainer

BackButton

AppBar

Your first app - Part 3: PageControl objects and navigation

Navigating between pages (HTML)

Adding app bars

Adding nav bars

HTML AppBar control sample

HTML NavBar control sample

Navigation and navigation history sample

Designers

Command patterns

Navigation patterns

Guidelines for app bars

Bottom app bar

Top app bar