WPF and Silverlight Edition Basic Library > HyperPanel > HyperPanel Features > Content |
By default the C1HyperPanel panel appears empty and contains no content.
Adding controls and other content to the panel is as easy as adding content to any other panel, Canvas, or Grid. For example, you can add a button to your C1HyperPanel panel:
To add a button to C1HyperPanel add the <Button> tag after the <c1:C1HyperPanel> tag so that it appears similar to the following:
XAML |
Copy Code
|
---|---|
<c1:C1HyperPanel Name="C1HyperPanel1"> <Button Height="50" Name="button1" Width="50"></Button> </c1:C1HyperPanel> |
To add a button to C1HyperPanel, switch to Code view and add the following UserControl_Loaded event handler or Window_Loaded event handler and code so it appears like the following:
Visual Basic |
Copy Code
|
---|---|
Private Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Dim button1 = New Button button1.Height = 50 button1.Width = 50 Me.C1HyperPanel1.Children.Add(button1) End Sub OR Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded Dim button1 = New Button button1.Height = 50 button1.Width = 50 Me.C1HyperPanel1.Children.Add(button1) End Sub |
C# |
Copy Code
|
---|---|
private void UserControl_Loaded(object sender, RoutedEventArgs e) { Button button1 = new Button(); button1.Height = 50; button1.Width = 50; this.c1HyperPanel1.Children.Add(button1); } OR private void Window_Loaded(object sender, RoutedEventArgs e) { Button button1 = new Button(); button1.Height = 50; button1.Width = 50; this.c1HyperPanel1.Children.Add(button1); } |
To add a button to C1HyperPanel during design time, complete the following:
Content Alignment
You can also change your content's alignment with the HorizontalContentAlignment and VerticalContentAlignment properties. The HorizontalContentAlignment and VerticalContentAlignment properties control how content in the C1HyperPanel panel is aligned within the panel. By default, both properties are set to Center and content is centered within the panel.
HorizontalContentAlignment options include Left, Center, Right, and Stretch. VerticalContentAlignment options include Top, Center, Bottom, and Stretch. If, for example, HorizontalContentAlignment was set to Left and VerticalContentAlignment was set to Bottom, the panel would appear in the bottom-left corner of the panel like in the following image: