【发布时间】:2017-01-13 13:33:59
【问题描述】:
我找不到操作以编程方式添加的画布子 UI 元素的方法。这是我在画布中添加孩子的代码。我想在运行时操纵每一个画布子节点。
有没有办法做到这一点?
Canvas = new Canvas();
canvas.Width = mapArea.ActualWidth;
canvas.Height = mapArea.ActualHeight;
mapArea.Children.Add(new UIElement() { Uid = "Camera" + index });
Image imageB = new Image();
{
imageB.Width = 60;
imageB.Source = camera;
}
mapArea.Children.Add(imageB);
Canvas.SetTop(imageB, PosX);
Canvas.SetLeft(imageB, PosY);
【问题讨论】:
-
画布画布=新画布(); UIElementCollection 集合 = 新 UIElementCollection(canvas, null); UIElement element = new UIElement() { Uid = "Camera" + index };集合.添加(元素);