WPF and Silverlight Learning notes (12)

Source: Internet
Author: User
Tags silverlight

WPF and Silverlight Learning Notes (12): WPF panel content model, decorator content model, and other

I. Panel content model

The Panel content model refers to controls that inherit from System.Windows.Controls.Panel, which are containers that can host other controls and child containers internally. The Panel content model contains containers that are:

Canvas

DockPanel

Grid

TabPanel

Toolbaro Verflowpanel

UniformGrid

StackPanel

Toolbarpanel

Virtualizingpanel

VirtualizingStackPanel

WrapPanel

< p> for the panel model, it contains a children property that represents the collection of all its child controls and child containers, which can be omitted from the XAML code <XXX. Children> tags, such as:

1: <StackPanel x:Name="mainPanel">
2:   <StackPanel x:Name="panelA">
3:      <StackPanel.Children>
4:        <Button>Button A</Button>
5:      </StackPanel.Children>
6:   </StackPanel>
7:    <Button>Button B</Button>
8:    <StackPanel x:Name="panelB">
9:    </StackPanel>
10: </StackPanel>

You can also dynamically add objects in children through code

1: // 定义一个 Button
2: Button btn = new Button();
3: btn.Content =  "Button C";
4:
5: // 将Button添加到StackPanel 中
6: panelB.Children.Add(btn);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.