Arranges child elements into a single line that can be oriented horizontally or vertically.
Namespace: DigitalRune.Game.UI.ControlsAssembly: DigitalRune.Game.UI (in DigitalRune.Game.UI.dll) Version: 1.1.0.0 (1.1.1.9392)
Syntax
Examples
The following examples shows how to create a button containing an icon and a text label.
| C# | |
|---|---|
// Create a horizontal stack panel containing an icon and a label. var buttonContentPanel = new StackPanel { Orientation = Orientation.Horizontal }; buttonContentPanel.Children.Add(new Image { Width = 16, Height = 16, Texture = content.Load<Texture2D>("Icons"), // Load existing texture. SourceRectangle = new Rectangle(0, 0, 16, 16) // Optional: Select region in texture. }); buttonContentPanel.Children.Add(new TextBlock { Margin = new Vector4F(4, 0, 0, 0), Text = "Label", VerticalAlignment = VerticalAlignment.Center, }); var button = new Button { Content = buttonContentPanel, Margin = new Vector4F(4), }; // To show the button, add it to an exising content control or panel. panel.Children.Add(button); // To handle button clicks simply add an event handler to the Click event. button.Click += OnButtonClicked; | |
Inheritance Hierarchy
System..::..Object
DigitalRune.Game..::..GameObject
DigitalRune.Game.UI.Controls..::..UIControl
DigitalRune.Game.UI.Controls..::..Panel
DigitalRune.Game.UI.Controls..::..StackPanel
DigitalRune.Game..::..GameObject
DigitalRune.Game.UI.Controls..::..UIControl
DigitalRune.Game.UI.Controls..::..Panel
DigitalRune.Game.UI.Controls..::..StackPanel