wpf 我在后台画了一个Ellipse,怎么设置坐标啊!! 急急急!!
1个回答
展开全部
如果窗口是canvas就是
Ellipse ellipse = new Ellipse();
ellipse.Width = 50;
ellipse.Height = 100;
ellipse.Stroke = new SolidColorBrush(Colors.Blue);
ellipse.Fill = new SolidColorBrush(Colors.Green);
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
canvas.Children.Add(ellipse);
如果是Grid
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
这两句就改成
ellipse.SetValue(Grid.ColumnProperty, 1);
ellipse.SetValue(Grid.RowProperty, 1);
数据都是举例
Ellipse ellipse = new Ellipse();
ellipse.Width = 50;
ellipse.Height = 100;
ellipse.Stroke = new SolidColorBrush(Colors.Blue);
ellipse.Fill = new SolidColorBrush(Colors.Green);
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
canvas.Children.Add(ellipse);
如果是Grid
ellipse.SetValue(Canvas.LeftProperty, 50D);
ellipse.SetValue(Canvas.TopProperty, 100D);
这两句就改成
ellipse.SetValue(Grid.ColumnProperty, 1);
ellipse.SetValue(Grid.RowProperty, 1);
数据都是举例
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询