几天来,我自己解决了答案。我继续通过我的 < code> Square 用户控制,并将其用于布局。
关于X/y 位置的绘图,我用了这个:
Point point = myElement.TransformToVisual(App.Current.RootVisual as FrameworkElement)).Transform(new Point(0, 0));
保存 XML 文件时出现故障, 因为银光 4 没有给予在浏览器中应用的高级权限 。 但我在保存按钮点击事件上使用了此选项 :
SaveFileDialog dlgSave = new SaveFileDialog();
dlgSave.DefaultExt = "xml";
dlgSave.Filter = "XML Files (XML)|*.xml;";
dlgSave.FilterIndex = 1;
strXML = "<?xml version="1.0" encoding="UTF-8"?>
" + myXML.ToString();//myXML is the XDocument I created globally and saved data in it
try
{
bool check = (bool)dlgSave.ShowDialog();
if (check)
{
using (Stream stream = dlgSave.OpenFile())
{
StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8);
sw.Write(strXML);
sw.Close();
stream.Close();
}
MessageBox.Show("XML Saved successfully");
}
catch (SecurityException)
{
MessageBox.Show("There seems to be an issue with saving XML file on the disk, please try again...", "Something s not right", MessageBoxButton.OK);
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Saving here requires authorised permissions", "Access Denied", MessageBoxButton.OK);
}