語言

NavigationViewItem.Icon 屬性

定義

會讓圖示顯示在選單項目文字旁邊。

public:
 property IconElement ^ Icon { IconElement ^ get(); void set(IconElement ^ value); };
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
IconElement Icon();

void Icon(IconElement value);
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
IconElement Icon();

void Icon(IconElement value);
public IconElement Icon { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] set; }
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
public IconElement Icon { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] set; }
var iconElement = navigationViewItem.icon;
navigationViewItem.icon = iconElement;
Public Property Icon As IconElement
<NavigationViewItem Icon="symbolName" .../>


<NavigationViewItem>
  <NavigationViewItem.Icon>
    iconElement
  </NavigationViewItem.Icon>
</NavigationViewItem>

屬性值

選單項目文字旁邊顯示的圖示。 預設是 null。

屬性
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackAttribute

備註

你可以從 符號 列舉中指派一個值,或是用 Unicode 字串指派 Segoe MDL2 Assets 字型中的字形。

你可以使用 Windows 附帶的字元地圖應用程式瀏覽字型的字形並找到它們的 Unicode 值。 接著,在 XAML 中使用 格式為「&#x/(UNICODE);」 ,或在程式碼中使用 格式為「\u/(UNICODE)」 ,其中 (UNICODE) 是字型檔案中指示位置的字形值。

Segoe MDL2 Assets 字型隨 Windows 10 一同推出,且每個版本可能會新增字形。 你應該確認你選擇的 Unicode 值是否存在於你專案目標的最低 SDK 建置版本中。

NavigationViewItem 也支援 AnimatedIcon。 如果你將 AnimatedIcon 設定為 Icon 屬性的值,NavigationViewItem 會根據控制項的狀態為你設定 AnimatedIcon 的狀態。

NavigationViewItem 會自動在 AnimatedIcon 上設定以下狀態:

  • 正常
  • PointerOver
  • 按下
  • 已選擇
  • 按下選擇
  • 指標懸停於選取項

適用於