This chapter introduces the container controls used for layout. If you do not know the basic concepts of Silverlight, refer to the related content of Internet power.
Silverlight panel
Panel has three common forms for different la s:
Stackpanel: horizontal and vertical arrangement of child elements
Wrappanel: child element levels and vertical arrangement, line feed display
Dockpanel: Align elements to the edge of the container
Wrappanel and dockpanel are used on Silverlight toolkit.
Panel has the background attribute. You can use a brush to define the background color. The Code is as follows: panel1.background = new solidcolorbrush (colors. aliceblue); written in XAML: <stackpanel X: Name = "Panel1" background = "# FFFF00"/>. Please note that there is another way to write this:
Figure 1
If you think this is too much trouble and there is no need at all, you will be wrong. You can use composite attributes to achieve multiple colors, such as gradient effects. For specific examples, refer to the resource of XAML.
Silverlight border
Panel can be a container with a background color, but no border. This requires the border control, which has common attributes: Background color, borderbrush border brush, borderthickness Border width, in pixels, cornerradius border rounded corner, and padding border spacing. The following small example adds a border to the button. It is clear that the border control is not only a stroke, but also a container control.
First, place a button control on the page, for example, <button X: name = "btn1" content = "click" margin = "10" width = "100" Height = "40"/>. Use the button as a sub-element and place it in border, the complete content is as follows:
Figure 2
Running effect:
Figure 3
Let's talk about this today. Next time, let's talk about the usage of each panel.
Copyright Internet power, from: http://www.foxitjob.com/2010/07/343.html