7
프로그래밍 방식으로 캔버스에 넣으려는 타원이 있습니다. 불행히도, 타원은 오른쪽 상단에만 그려집니다. 어떤 도움이 필요합니까?캔버스 내에서 타원 위치 추가
SolidColorBrush newColor = HotSquare(col);
Color newCol = getCol(col);
Color newCol2 = getCol2(col);
Ellipse el1 = new Ellipse();
el1.Height = 40;
el1.Width = 40;
RadialGradientBrush rgb = new RadialGradientBrush();
GradientStop gsa = new GradientStop();
el1.StrokeThickness = 3;
el1.Stroke = newColor;
el1.StrokeDashArray = new DoubleCollection() { 6, 6 };
gsa.Color = newCol;
gsa.Offset = 0;
rgb.GradientStops.Add(gsa);
GradientStop gsb = new GradientStop();
gsb.Color = newCol2;
gsb.Offset = 1;
rgb.GradientStops.Add(gsb);
el1.Fill = rgb;
Ellipse el2 = new Ellipse();
el2.Height = 40;
el2.Width = 40;
el2.StrokeThickness = 3;
el2.Stroke = newColor;
//el2.Fill = new SolidColorBrush(Colors.Transparent);
Canvas canvas = new Canvas();
canvas.Children.Add(el1);
//canvas.Children.Add(el2);
TextBlock txt = new TextBlock();
txt.Text = "\n " + amnt.ToString();
txt.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
txt.Height = 60;
txt.Width = 60;
txt.HorizontalAlignment = HorizontalAlignment.Center;
//txt.VerticalAlignment = VerticalAlignment.Bottom;
txt.FontSize = 12;
canvas.Children.Add(txt);
Border border = new Border();
border.BorderBrush = newColor;
border.BorderThickness = new Thickness(2);
border.Child = canvas;
LocationRect lr = new LocationRect(North, West, South, East);
HotspotLayer.AddChild(ele, lr);
Xaml에서 설명하지 않는 이유가 있습니까? – AnthonyWJones
프로그래밍 방식으로 추가하기 때문에 런타임시에만 XAML을 직접 조작 할 필요가 없습니다. –