//在Window_Loaded事件里粘贴如下代码
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Grid g = new Grid()
g.HorizontalAlignment = HorizontalAlignment.Stretch
g.VerticalAlignment = VerticalAlignment.Stretch
g.Background = Brushes.Blue
ScrollViewer s = new ScrollViewer()
s.Width = 100
s.Height = 100
Label l = new Label()
Oo巴黎迷雾_ | 分类:C#/.NET | 浏览17次
请示范一个简单的完整例子,不是在form里, 而是在wpf grid里的scrollviewer控件添加label控件。"
s.Content = l
this.AddChild(s)
}
Button b = new Button()b.Content = "按钮1"
b.Height = 50
b.Width = 80
groupBox1.Content = b
如果需要添加多个,需要用到布局控件了stackpal等
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)