試驗平台
在Microsoft
讓人奇怪的是
StackPanel類是Panel的派生類
有如下幾個屬性方法控制堆疊方式
public enum HorizontalAlignment
{
Left =
Center =
Right =
Stretch =
}
public enum VerticalAlignment
{
Top =
Center =
Bottom =
Stretch =
}
完整的代碼如下
using System;
using Microsoft
using Microsoft
using Microsoft
using Microsoft
using Microsoft
using Microsoft
namespace MFWindow
{
public class Program : Microsoft
{
public static void Main()
{
//創建窗體
WindowsDrawing win = new WindowsDrawing();
//程序運行
new Program()
}
internal sealed class WindowsDrawing : Window
{
public WindowsDrawing()
{
this
this
//可設置顯示方向(水平
//StackPanel panel = new StackPanel(Orientation
StackPanel panel = new StackPanel(Orientation
//設置邊界空白
panel
//設置對象堆疊的方式
panel
panel
this
//添加文本
Text txt = new Text(Resources
//不能設置left
txt
txt
panel
//添加不同的形狀對象
Shape[] shapes = new Shape[]
{
new Ellipse()
new Line()
new Polygon(new Int
new Rectangle()
};
//設置形狀對象必要的參數(各對象不能重疊
foreach (Shape s in shapes)
{
s
s
//不能設置left
s
s
panel
}
}
}
}
}
僅修改這句代碼 StackPanel panel = new StackPanel(Orientation
.NET編程免費提供,內容來源於互聯網,本文歸原作者所有。