NavigationBarItem
Namespace: Wisej.Web.Ext.NavigationBar
Assembly: Wisej.Web.Ext.NavigationBar (4.1.0.0)
Represents a navigation item in the NavigationBar control.
- C#
- VB.NET
public class NavigationBarItem : FlexLayoutPanel
Public Class NavigationBarItem
Inherits FlexLayoutPanel
A NavigationBarItem displays an Icon, a title (Text), an optional info "bubble" (InfoText), an optional shortcut button (ShowShortcut) and an open/close icon when it contains child items in its Items collection.
Constructors
NavigationBarItem()
Initializes a new instance of the NavigationBarItem class.
Properties
AllowHtml
Boolean: Returns or sets a value indicating that the control can display HTML in the Text property. (Default: False)
BackColor
Color: Returns or sets the background color.
The color is applied to the header of the item (icon and title row), not to the area containing the child items.
Cursor
Cursor: Returns or sets the cursor displayed when the mouse pointer is over the NavigationBarItem. (Default: Cursor: Hand)
Expanded
Boolean: Returns or sets whether the child items are expanded (visible). (Default: False)
Changing the value fires the Expand or Collapse event. When CompactView is true, setting this property to true doesn't expand the item: if it's a top-level item with child items, its children are shown in a popup NavigationBarMenu and the value remains false.
Example:
Expanding all the top-level items:
foreach (var item in this.navigationBar1.Items)
{
item.Expanded = true;
}
ExpandOnClick
Boolean: Returns or sets whether to expand or collapse the item when clicking the item rather than having to click the open/close icon. (Default: True)
ForeColor
Color: Returns or sets the text color.
The color is applied to the header of the item (icon and title row), not to the child items.
HasChildren
Boolean: Returns whether the NavigationBarItem contains child items.
Hidden
Boolean: Returns or sets whether the NavigationBarItem is hidden. (Default: False)
Setting this property to true sets Visible to false, and vice versa. Unlike Visible, this property is serializable by the designer.
Icon
String: Returns or sets the icon of the NavigationBarItem. (Default: null)
The value can be a URL, a relative path to an image file, or the name of a theme icon. The icon is the only part of the item that remains visible when CompactView is true.
IconVisible
Boolean: Returns or sets whether the item's icon is visible. (Default: True)
InfoText
String: Returns or sets the text to show in the info "bubble" next to the item. (Default: "")
The bubble is visible only when the text is not empty and CompactView is false. Clicking it fires the InfoClick and ItemInfoClick events.
Example:
Showing the number of unread messages and hiding the bubble when there are none:
var count = GetUnreadMessageCount();
this.navigationBar1.Items["inbox"].InfoText = count > 0 ? count.ToString() : "";
this.navigationBar1.Items["inbox"].InfoTextBackColor = Color.Red;
this.navigationBar1.Items["inbox"].InfoTextForeColor = Color.White;
InfoTextBackColor
Color: Returns or sets the background color of the info "bubble".
InfoTextForeColor
Color: Returns or sets the text color of the info "bubble".
Items
NavigationBarItemCollection: Returns the collection of child items to display in the NavigationBarItem.
Child items are visible only when the item is Expanded. Adding a child item shows the open/close icon and applies the ItemHeight and Indentation of the owner NavigationBar.
Example:
Adding child items and expanding the parent:
var reports = this.navigationBar1.Items["reports"];
reports.Items.Add("sales", "Sales", "Images/sales.svg");
reports.Items.Add("inventory", "Inventory", "Images/inventory.svg");
reports.Expanded = true;
Level
Int32: Returns the indentation level of this NavigationBarItem item.
Top-level items have level 0, their children level 1, and so on.
NavigationBar
NavigationBar: Returns the owner NavigationBar.
Returns null when the item has not been added to a NavigationBar (directly or through a parent item) yet.
Parent
NavigationBarItem: Returns the parent NavigationBarItem or null.
Returns null for top-level items, which belong directly to the Items collection. This property hides Parent, which returns the internal container panel.
Selected
Boolean: Returns whether the NavigationBarItem is the currently selected item.
To select an item, set the SelectedItem property. The selected item is rendered using the "selected" state of the theme.
ShortcutIcon
String: Returns or sets the shortcut icon. (Default: "spinner-plus")
The value can be a URL, a relative path to an image file, or the name of a theme icon. The icon is displayed only when ShowShortcut is true.
ShowShortcut
Boolean: Returns or sets whether the shortcut button is visible. (Default: False)
The shortcut button displays the ShortcutIcon and it's hidden when CompactView is true. Clicking it fires the ShortcutClick and ItemShortcutClick events.
Example:
Using the shortcut button to create a new record:
var customers = this.navigationBar1.Items["customers"];
customers.ShowShortcut = true;
customers.ShortcutIcon = "icon-add";
customers.ShortcutClick += (s, e) => new CustomerForm().Show();
Text
String: Returns or sets the title of the NavigationBarItem. (Default: "")
The title is hidden when CompactView is true; in that case it's shown as the tooltip of the item unless ToolTipText is set.
Visible
Methods
CreateItemMenu()
Creates the menu used to show child items when the CompactView property is set to true.
Returns: NavigationBarMenu. A NavigationBarMenu instance.
Dispose(disposing)
Clean up any resources being used.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | true if managed resources should be disposed; otherwise, false. |
OnCollapse(e)
Fires the Collapsed event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Not used |
OnExpand(e)
Fires the Expanded event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Not used |
OnInfoClick(e)
Fires the InfoClick event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Not used |
OnParentChanged(e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs |
OnShortcutClick(e)
Fires the ShortcutClick event.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Not used |
ResetBackColor()
Resets the BackColor property to its default value.
Example:
Restoring the themed background after highlighting an item:
this.navigationBarItem1.BackColor = Color.LightYellow;
// ...
this.navigationBarItem1.ResetBackColor();
ResetForeColor()
Resets the ForeColor property to its default value.
Example:
Restoring the themed text color:
this.navigationBarItem1.ForeColor = Color.Red;
// ...
this.navigationBarItem1.ResetForeColor();
Update()
Updates the client side widget.
In design mode it also updates the owner NavigationBar.
Example:
Refreshing the item after changing several properties:
this.navigationBarItem1.Update();
Events
Collapse
EventHandler Fired when the NavigationBarItem is collapsed to hide child items.
Expand
EventHandler Fired when the NavigationBarItem is expanded to show the child items.
InfoClick
EventHandler Fired when the user clicks the info "bubble".
MouseEnter
MouseLeave
ShortcutClick
EventHandler Fired when the user clicks the shortcut icon.