MenuBar 類別

定義

代表專門的容器,其會在水平列中顯示一組功能表,一般會出現在應用程式視窗的頂端。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

/// [Microsoft.UI.Xaml.MUXContractProperty(version=7)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Version(1)]
/// [Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
class MenuBar : Control
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Version(1)]
/// [Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=7)]
class MenuBar : Control
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.XamlContract, 65536)]
class MenuBar : Control
[Microsoft.UI.Xaml.MUXContractProperty(version=7)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Version(1)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
public class MenuBar : Control
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Version(1)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
[Microsoft.UI.Xaml.CustomAttributes.MUXContractProperty(version=7)]
public class MenuBar : Control
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.UI.Xaml.Markup.ContentProperty(Name="Items")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.XamlContract), 65536)]
public class MenuBar : Control
Public Class MenuBar
Inherits Control
繼承
MenuBar
屬性
Microsoft.UI.Xaml.MUXContractPropertyAttribute MarshalingBehaviorAttribute ThreadingAttribute VersionAttribute ContentPropertyAttribute Microsoft.UI.Xaml.CustomAttributes.MUXContractPropertyAttribute ContractVersionAttribute

範例

提示

如需詳細資訊、設計指引和程式碼範例,請參閱 功能表飛出視窗和功能表列

WinUI 2 資源庫應用程式包含大部分 WinUI 2 控制項、特性和功能的互動式範例。 從 Microsoft Store 取得應用程式,或在 GitHub上取得原始程式碼。

備註

控制項樣式和範本

您可以修改預設 的 StyleControlTemplate ,讓控制項具有唯一的外觀。 如需修改控制項樣式和範本的相關資訊,請參閱 XAML 樣式。 定義控制面板的預設樣式、範本和資源會包含在 檔案中 generic.xaml 。 為了設計目的, generic.xaml 會與 WinUI (Microsoft.UI.Xaml) NuGet 套件一起安裝。 根據預設,此位置為 \Users\<username>\.nuget\packages\microsoft.ui.xaml\<version>\lib\uap10.0\Microsoft.UI.Xaml\Themes\generic.xaml。 不同 WinUI 版本的樣式和資源可能會有不同的值。

XAML 也包含資源,可讓您用來修改不同視覺狀態中控制項的色彩,而不需修改控制項範本。 修改這些資源是慣用的設定屬性,例如 BackgroundForeground。 如需詳細資訊,請參閱XAML 樣式文章的輕量型樣式一節。

建構函式

MenuBar()

初始化 MenuBar 類別 的新實例。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

屬性

Items

取得最上層功能表項目的集合。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

ItemsProperty

識別 Items 相依性屬性。

本檔適用于 Windows 應用程式 SDK 中適用于 WinUI 的 WinUI 2 for UWP (,請參閱Windows 應用程式 SDK命名空間) 。

適用於

另請參閱