MenuBar Klasse

Definition

Stellt einen spezialisierten Container dar, der eine Reihe von Menüs in einer horizontalen Zeile darstellt, normalerweise oben im Fenster einer App.

Diese Dokumentation gilt für WinUI 2 für UWP (für WinUI im Windows App SDK siehe Windows App SDK Namespaces).

/// [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
Vererbung
MenuBar
Attribute
Microsoft.UI.Xaml.MUXContractPropertyAttribute MarshalingBehaviorAttribute ThreadingAttribute VersionAttribute ContentPropertyAttribute Microsoft.UI.Xaml.CustomAttributes.MUXContractPropertyAttribute ContractVersionAttribute

Beispiele

Tipp

Weitere Informationen, Entwurfsanleitungen und Codebeispiele finden Sie unter Menüflyout und Menüleiste.

Die App WinUI 2-Katalog umfasst interaktive Beispiele für die meisten WinUI 2-Steuerelemente, -Features und -Funktionen. Rufen Sie die App aus dem Microsoft Store oder den Quellcode auf GitHub ab.

Hinweise

Steuerelementstil und -vorlage

Sie können den Standardstil und die ControlTemplate ändern, um dem Steuerelement ein eindeutiges Erscheinungsbild zu verleihen. Informationen zum Ändern des Stils und der Vorlage eines Steuerelements finden Sie unter XAML-Formatvorlagen. Der Standardstil, die Vorlage und die Ressourcen, die das Erscheinungsbild des Steuerelements definieren, sind in der generic.xaml Datei enthalten. Zu Entwurfszwecken generic.xaml wird mit dem NuGet-Paket WinUI (Microsoft.UI.Xaml) installiert. Standardmäßig ist der Speicherort \Users\<username>\.nuget\packages\microsoft.ui.xaml\<version>\lib\uap10.0\Microsoft.UI.Xaml\Themes\generic.xaml. Stile und Ressourcen aus verschiedenen WinUI-Versionen können unterschiedliche Werte aufweisen.

XAML enthält auch Ressourcen, mit denen Sie die Farben eines Steuerelements in verschiedenen visuellen Zuständen ändern können, ohne die Steuerelementvorlage zu ändern. Das Ändern dieser Ressourcen wird bevorzugt, um Eigenschaften wie Hintergrund und Vordergrund festzulegen. Weitere Informationen finden Sie im Abschnitt Leichtes Formatieren des Artikels XAML-Formatvorlagen .

Konstruktoren

MenuBar()

Initialisiert eine neue instance der MenuBar-Klasse.

Diese Dokumentation gilt für WinUI 2 für UWP (für WinUI im Windows App SDK siehe Windows App SDK Namespaces).

Eigenschaften

Items

Ruft die Auflistung der Menüelemente der obersten Ebene ab.

Diese Dokumentation gilt für WinUI 2 für UWP (für WinUI im Windows App SDK siehe Windows App SDK Namespaces).

ItemsProperty

Identifiziert die Items-Abhängigkeitseigenschaft.

Diese Dokumentation gilt für WinUI 2 für UWP (für WinUI im Windows App SDK siehe Windows App SDK Namespaces).

Gilt für:

Weitere Informationen