獲取COORDS從控制:
foreach (UIElement el in mapGrid.Children)
{
XElement control = new XElement("control");
var ele = (HumanWorkspace)el;
Vector v = VisualTreeHelper.GetOffset(el);
double x = v.X;
double y = v.Y;
XAttribute atd = new XAttribute("direction", ele.Direction.ToString("d"));
XAttribute atx = new XAttribute("x", v.X.ToString());
XAttribute aty = new XAttribute("y", v.Y.ToString());
control.Add(atd);
control.Add(atx);
control.Add(aty);
controls.Add(control);
}
設置COORDS加載狀態時:
foreach (XElement ele in doc.Elements("controls"))
{
var con = new HumanWorkspace();
con.Direction = (WorkspaceDirection)int.Parse(ele.Attribute("direction").Value);
con.SetValue(TranslateTransform.XProperty, double.Parse(ele.Attribute("x").Value));
con.SetValue(TranslateTransform.YProperty, double.Parse(ele.Attribute("y").Value));
}
什麼類的項目? –
項目是文本塊 – thewayman