Hello everyone,
I'm currently stucked with the following situation.
I'm generating via a ViewModel the shapes for my toolbox. This is done via a property binding.
01.
Public
ReadOnly
Property
CostCenterToolbox
As
ObservableCollection(Of DiagramGallery)
02.
Get
03.
Dim
galleryCollection =
New
ObservableCollection(Of DiagramGallery)()
04.
Dim
gallery
As
New
DiagramGallery
With
{.Header =
"Cost centers"
}
05.
06.
costCenterDataTable = ParameterProduction.Instance.Open_ParCostCenter
07.
For
Each
row
As
DataRow
In
costCenterDataTable
08.
Dim
node =
New
WorkflowCostCenterNode
With
09.
{
10.
.Content = row.Item(
"costCenter"
) & vbCrLf & row.Item(
"Description"
),
11.
.TreeId= 0,
12.
.ProcessId = 0,
13.
.CostCenter = row.Item(
"costCenter"
),
14.
.Description = row.Item(
"Description"
)
15.
}
16.
gallery.Shapes.Add(node)
17.
Next
18.
galleryCollection.Add(gallery)
19.
20.
Return
galleryCollection
21.
End
Get
22.
End
Property
On the right side of the toolbox there is my diagram, which initially loads an existing workflow.
Now the problem is, that when dragging a shape from the toolbox to the diagram the dropped shape doesn't have any information about the node properties I gave it (in this case TreeId, ProcessId, CostCenter, Description are all Nothing).
As the documentation says, I need to serialize my custom properties, so that the diagram recognizes them.
The initially loaded workflow to the diagram is done via a GraphSource, which works perfectly (with the same node properties from above). In the GraphSource class I have those SerializeNode and DeserializeNode methods overriden.
But for the toolbox the nodes aren't in a graph source but added directly to the gallery and then to the gallerycollection (see code snippet above).
This might be the problem.
Is it possible to create the nodes, add them to a graph source object and then add them to the toolbox gallery?
Otherwise, how can I achieve, that when dragging the shape (initially created with the node and custom properties) from the toolbox to my diagram, that the node behind the shape has the custom property values I've initially set. Maybe the node properties are already lost, when the shapes are loaded into the toolbox?
I've read the following documentations without success :-(
- http://docs.telerik.com/devtools/wpf/controls/raddiagram/howto/drag-custom-toolboxitem
Any hints and maybe short examples are very welcome