?Saving collection of object as part of Node data

Hi i have following data structure.In here the property

ObservableCollection Items is part of the sturcture which will be binded to the DataGrid in the Node Data templated (refer the code and xaml below).While saving the Node data using the below code we want to save what ever the collection that Items property holds to the database (through service) and we want to retireve it back so that we can populate the datagrid while showing the node on the diagram.

************************************************************

var model = this.rcDiagram.Model as GraphLinksModel;

XElement root = model.Save("ND","LD",RuleConstant.LinkData);

***************************************

public class ItemEntity : BaseEntity {

string itemNumber; public string ItemNumber { get { return this.itemNumber; } set { this.itemNumber = value; this.RaisePropertyChanged("ItemNumber"); } }

string displayName; public string DisplayName { get { return this.displayName; } set { this.displayName = value; this.RaisePropertyChanged("DisplayName"); } }

string description; public string Description { get { return this.description; } set { this.description = value; this.RaisePropertyChanged("Description"); } } }

****************************************

using System.Windows.Shapes; using Northwoods.GoXam.Model; using Northwoods.GoXam; using System.Xml.Linq;using System.Collections.Generic; using System.Collections.ObjectModel;

namespace iCore.UI.Common.RuleData { public class ND : GraphLinksModelNodeData { private bool highlight = false;

public bool Highlight { get { return highlight; } set { bool old = highlight; if (old != value) { highlight = value; RaisePropertyChanged("Highlight", old, value); } } }

private double opacity = 1.00; public double Opacity { get { return opacity; } set { double old = opacity; if (old != value) { opacity = value; RaisePropertyChanged("Opacity", old, value); } } }

private string gID;

///

/// Get or Sets the Group Id /// public string GID { get { return this.gID; } set { string oldValue = this.gID; if (oldValue != value) { this.gID = value; RaisePropertyChanged("GID", oldValue, value); } } }

private NodeFigure _Figure = NodeFigure.Rectangle;

///

/// Get or Sets the Figure type /// public NodeFigure Figure { get { return _Figure; } set { if (_Figure != value) { NodeFigure old = _Figure; _Figure = value; RaisePropertyChanged("Figure", old, value); } } }

///

/// Method to create XElement from the properties of ND /// /// XName /// XElement public override XElement MakeXElement(XName n) { XElement e = base.MakeXElement(n); e.Add(XHelper.AttributeEnum("Figure", this.Figure, NodeFigure.Rectangle)); e.Add(XHelper.Attribute("GID", this.GID, "")); return e; }

///

/// Method to extract value (Properties of ND) from XElement /// /// XElement public override void LoadFromXElement(XElement e) { base.LoadFromXElement(e); this.Figure = XHelper.ReadEnum("Figure", e, NodeFigure.Rectangle); this.GID = XHelper.Read("GID", e, ""); }

private ObservableCollection items = new ObservableCollection();

///

/// Items for ND Element /// public ObservableCollection Items { get { return items; } set { if (items != value) { System.Collections.IEnumerable old = items; items = value; RaisePropertyChanged("Items", old, value); } } } } }

***************************XAML Code **************

************Xaml code*******************

<go:SpotPanel Background="{x:Null}" DataContext="{Binding}"

go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"

Style="{StaticResource SpotPanelStyle}">

<Path x:Name="Shape" go:NodePanel.Figure="{Binding Path=Data.Figure}"

Stroke="{Binding Path=Data.Highlight, Converter={StaticResource theStrokeColorConverter}}"

StrokeThickness="{Binding Path=Data.Highlight, Converter={StaticResource theStrokeThicknessConverter}}"

Style="{StaticResource NodeShapeStyleAll}" />

<ListBox x:Name="listboxCgItems" Background="Silver" FontSize="10"

ItemsSource="{Binding Path=Data.Items}">

********************************

*

***************************************************

It seems you have already started implementing the MakeXElement and LoadFromXElement methods. You just need to finish them to handle the Items collection and any other data that you care about, if any.

Hi…Thanks for your quick reply…

refering the above image... the following is the generated ND Xml..


Please guide us where can we and how can we add the collection details to the ND XML

You have a number of choices for the kind of XML you could generate (i.e. its schema). You can learn more about Linq to XML at Programming Guide.