silverlight绘图DiagramLite
请问有谁用过MindFusion团队开发的DiagramLite,在微软中国网站里面的silverlight站点下载的,我遇到了一个问题,在使用LoadFromString(String xml)方法加载diagram时出问题。先用diagram.SaveToString(SaveToStringFormat.Xml)把diagram以字符串存起来,然后用LoadFromString加载,但是加载不成功。我用了自定义的node,如下:
namespace SaveLoadSample
{
public class OrgChartNode : ShapeNode
{
public OrgChartNode()
{
DefaultStyleKey = typeof(OrgChartNode);
}
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(
"Title",
typeof(string),
typeof(OrgChartNode),
new PropertyMetadata(""));
public string FullName
{
get { return (string)GetValue(FullNameProperty); }
set { SetValue(FullNameProperty, value); }
}
public static readonly DependencyProperty FullNameProperty = DependencyProperty.Register(
"FullName",
typeof(string),
typeof(OrgChartNode),
new PropertyMetadata(""));
// serialization support for custom properties
protected override void SaveToXml(System.Xml.Linq.XElement xmlElement, XmlPersistContext context)
{
base.SaveToXml(xmlElement, context);
context.WriteString(Title, "Title", xmlElement);
context.WriteString(FullName, "FullName", xmlElement);
}
protected override void LoadFromXml(System.Xml.Linq.XElement xmlElement, XmlPersistContext context)
{
base.LoadFromXml(xmlElement, context);
Title = context.ReadString("Title", xmlElement);
FullName = context.ReadString("FullName", xmlElement);
}
// undo and redo support
protected override DiagramItemState CreateState()
{
return new OrgChartNodeState();
}
protected override DiagramItemState SaveState()
{
var state = (OrgChartNodeState)base.SaveState();
state.Title = Title;
state.FullName = FullName;
return state;
}
protected override void RestoreState(DiagramItemState itemState)
{
base.RestoreState(itemState);
var state = (OrgChartNodeState)itemState;
Title = state.Title;
FullName = state.FullName;
}
}
}
[解决办法]
DiagramLite,这个没有用过,晚上回家下载一个试试看,先帮你顶,看看其他人是不是能帮你。