//新建Window,把其默认的Grid元素删除,然后
//在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)
}
//新建Window,把其默认的Grid元素删除,然后//在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()
l.Content = @"wpf 控件内 动态添加 控件
Oo巴黎迷雾_ | 分类:C#/.NET | 浏览17次
请示范一个简单的完整例子,不是在form里, 而是在wpf grid里的scrollviewer控件添加label控件。"
s.Content = l
this.AddChild(s)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)