Udostępnij za pośrednictwem


NavigationViewItem.Icon Property

Definition

Gets or sets the icon to show next to the menu item text.

Equivalent WinUI 2 API for UWP: Microsoft.UI.Xaml.Controls.NavigationViewItem.Icon (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

public:
 property IconElement ^ Icon { IconElement ^ get(); void set(IconElement ^ value); };
IconElement Icon();

void Icon(IconElement value);
public IconElement Icon { get; set; }
var iconElement = navigationViewItem.icon;
navigationViewItem.icon = iconElement;
Public Property Icon As IconElement
<NavigationViewItem Icon="symbolName" .../>
- or -
<NavigationViewItem>
  <NavigationViewItem.Icon>
    iconElement
  </NavigationViewItem.Icon>
</NavigationViewItem>

Property Value

The icon to show next to the menu item text. The default in null.

Remarks

You can assign a value from the Symbol enumeration, or a Unicode string that references a glyph in the Segoe MDL2 Assets font.

You can use the Character Map application that comes with Windows to browse the font's glyphs and find their Unicode values. Then, use the format "&#x(UNICODE);" in XAML, or the format "\u(UNICODE)" in code, where (UNICODE) is the value of the glyph that indicates the location in the font file. See FontIcon for more examples.

The Segoe MDL2 Assets font ships with Windows 10, and new glyphs might be added in every release. You should verify that the Unicode value you choose is available in the minimum SDK build version your project targets.

Applies to

See also