トレーニング
モジュール
.NET MAUI XAML ページのレイアウトをカスタマイズする - Training
StackLayout と Grid を使用して、さまざまなデバイス全体で一貫したユーザー インターフェイスを作成します。
このブラウザーはサポートされなくなりました。
Microsoft Edge にアップグレードすると、最新の機能、セキュリティ更新プログラム、およびテクニカル サポートを利用できます。
ドッキングを使用して ToolStrip コントロールを正しく配置するには、フォームの z オーダーでコントロールを正しく配置する必要があります。
次のコード例では、z オーダーを指定して、ToolStrip コントロールとドッキング MenuStrip コントロールを配置する方法を示します。
public Form2()
{
// Create a new ToolStrip control.
ToolStrip ts = new ToolStrip();
// Populate the ToolStrip control.
ts.Items.Add("Apples");
ts.Items.Add("Oranges");
ts.Items.Add("Pears");
ts.Items.Add(
"Change Colors",
null,
new EventHandler(ChangeColors_Click));
// Create a new MenuStrip.
MenuStrip ms = new MenuStrip();
// Dock the MenuStrip control to the top of the form.
ms.Dock = DockStyle.Top;
// Add the top-level menu items.
ms.Items.Add("File");
ms.Items.Add("Edit");
ms.Items.Add("View");
ms.Items.Add("Window");
// Add the ToolStrip to Controls collection.
this.Controls.Add(ts);
// Add the MenuStrip control last.
// This is important for correct placement in the z-order.
this.Controls.Add(ms);
}
Class Form2
Inherits Form
Public Sub New()
' Create a new ToolStrip control.
Dim ts As New ToolStrip()
' Populate the ToolStrip control.
ts.Items.Add("Apples")
ts.Items.Add("Oranges")
ts.Items.Add("Pears")
ts.Items.Add("Change Colors", Nothing, New EventHandler(AddressOf ChangeColors_Click))
' Create a new MenuStrip.
Dim ms As New MenuStrip()
' Dock the MenuStrip control to the top of the form.
ms.Dock = DockStyle.Top
' Add the top-level menu items.
ms.Items.Add("File")
ms.Items.Add("Edit")
ms.Items.Add("View")
ms.Items.Add("Window")
' Add the ToolStrip to Controls collection.
Me.Controls.Add(ts)
' Add the MenuStrip control last.
' This is important for correct placement in the z-order.
Me.Controls.Add(ms)
End Sub
' This event handler is invoked when the "Change colors"
' ToolStripItem is clicked. It assigns the Renderer
' property for the ToolStrip control.
Sub ChangeColors_Click(ByVal sender As Object, ByVal e As EventArgs)
ToolStripManager.Renderer = New ToolStripProfessionalRenderer(New CustomProfessionalColors())
End Sub
End Class
z オーダーは、ToolStrip と MenuStrip の順序によって決まります。
コントロールがフォームの Controls コレクションに追加されます。
// Add the ToolStrip to Controls collection.
this.Controls.Add(ts);
// Add the MenuStrip control last.
// This is important for correct placement in the z-order.
this.Controls.Add(ms);
' Add the ToolStrip to Controls collection.
Me.Controls.Add(ts)
' Add the MenuStrip control last.
' This is important for correct placement in the z-order.
Me.Controls.Add(ms)
Add メソッドに対するこれらの呼び出しの順序を逆にして、レイアウトに対する効果を表示します。
この例では、次のものが必要です。
.NET Desktop feedback に関するフィードバック
.NET Desktop feedback はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。
トレーニング
モジュール
.NET MAUI XAML ページのレイアウトをカスタマイズする - Training
StackLayout と Grid を使用して、さまざまなデバイス全体で一貫したユーザー インターフェイスを作成します。