Hi Walter.
Currently I am implementing export of a Silverlight GoXam diagram to a few output formats (SVG, Visio) for our business needs and I faced the following problem.
When I query Diagram.Nodes and examine their location and appearance (to reproduce these in an output file) sometimes it happens that Node.ActualWidth and Node.ActualHeight are equal to zero.
Here is actions sequense:
- the diagram is created and filled with data; all the nodes and links are there and look properly;
- the user clicks “Export” btn.;
- the diagram.Nodes collection is iterated in order to query nodes appearance properties and export this information.
Here is how I examine nodes:
private SvgElement CreateSvgNode(Node node)
{
var mainBorder = ((Border)node.VisualElement.FindName(“MainBorder”));
var rect = new SvgRect
{
Width = border.ActualWidth,
Height = border.ActualHeight,
};
…
var svg = new SvgElement();
svg.Add(rect);
…
return svg;
}
Here is node template I use:
In the bold lines I get ActualWidth and ActualHeight of a node’s inner element and sometimes they both happen to be equal to zero. In these cases ActualWidth and ActualHeight of the node itself and of all node’s child elements are zeros too.
This behaviour occurs mainly with large diagrams containing many nodes with IsSubGraph == true, IsSubgraphExpanded == true. The first idea was that “zero” nodes are just not rendered because of being outside of viewport. But this occurs also if I zoom out the diagram to fit the diagram bounds.
Could you give me some advice about what am I doing wrong and what is the best approach to examine node’s elements actual size in runtime?