I’d like to ask some questions regarding the use of custom layers. I’ve also noticed a behaviour which I’m not sure is a bug or not.
The first question is what is the proper way to instantiate and use custom layers?
Currently I’m doing the following:
var nodeLayer = new NodeLayer();
nodeLayer.Id = Guid.NewGuid().ToString();
diagram.Panel.Children.Add(nodeLayer);
Is this the correct way of doing it?
Secondly, do custom layers enroll in transactions? For example, If I add a custom layer during a transaction and then rollback the transaction, is the custom layer automatically removed? Are property changes of a custom layer tracked by a transaction?
Lastly, I noticed an odd behaviour regarding custom layers.
This is the current process:
Create custom link and node layers and add them to the diagram
Create nodes and links
Add nodes and links to a group
Bind the group, nodes and links to the custom layers using the Part.LayerName dependency property
The first time I perform this process it works as expected. However, If I repeat the process a second time, the links do not plot properly. See the image below: (the group on left is when I execute the process the first time. The group on the right is when I execute the process the second time)
No, the insertion or removal or modification of Layers do not have any changes recorded in the UndoManager. In fact the same is true for changes to the Diagram itself or to all of the FrameworkElements that constitute your Nodes and Links. It’s just changes to the Model that get recorded in the UndoManager.
Regarding the second problem, you might want to try the DLL that I just sent you before I read this forum post. I have no idea if that will help or not, but it wouldn’t hurt to try, since I believe it does address these problems with Silverlight that you have pointed out before.
Thereby making nodes and links use the same NodeLayer, then the issue would resolve itself. However, I’m not sure if this is a hack or fortunate coincidence. Can you please advise?
What actually happens in that case is that when adding a Link it searches for the Layer with the node layer’s GUID. It won’t find it, because it only searches LinkLayers – it cannot consider any NodeLayers. That results in the Link being added to the default LinkLayer.
Oh, no, I doubt that it is your problem. It has to do with how Silverlight loses some internal state when an element is removed from the visual tree or when it is not visible, and with what happens with how GoXam measures objects when they are not visible. Unfortunately it is quite different from WPF, which handles these unusual cases much more reasonably, from our point of view.
[quote]Oh, no, I doubt that it is your problem. It has to do with how Silverlight loses some internal state when an element is removed from the visual tree or when it is not visible, and with what happens with how GoXam measures objects when they are not visible. Unfortunately it is quite different from WPF, which handles these unusual cases much more reasonably, from our point of view.[/quote]
Sorry to revive an old thread but I’m trying to think of a robust way to deal with the issue where Silverlight or GoXam has problems measuring items that aren’t visible yet.
My initial plan was to use delays between transactions in the hope that the layout system had enough time to do what it needed to do before I started doing any UI manipulation.
For example, something similar to this pseudo-code:
<span ="Apple-tab-span" style="white-space:pre"> </span>Dispatcher.BeginInvoke(() =>{
<span ="Apple-tab-span" style="white-space:pre"> </span>//Create diagram modes
<span ="Apple-tab-span" style="white-space:pre"> </span>});
<span ="Apple-tab-span" style="white-space:pre"> </span><b>Delay X milliseconds using a timer/task</b>
<span ="Apple-tab-span" style="white-space:pre"> </span>Dispatcher.BeginInvoke(() =>{
<span ="Apple-tab-span" style="white-space:pre"> </span>//Center a diagram part
<span ="Apple-tab-span" style="white-space:pre"> </span>Diagram.Panel.CenterPart(part);
<span ="Apple-tab-span" style="white-space:pre"> </span>});
However, regardless of how long I make the delay the results are always unreliable.
Can you suggest a way that I might be able to deal with this issue?