[Solved] Clearing Loading PartsManager, Palette

Hi,

I'm using the Diagram in a tabbed environment. The issue is when I switch tab & come back the PartManager is not able to find nodes. I inspected its content & found its NodesSource containing all the nodes in the diagram. But, when I try to get a Node object using FindNodeForData it is returning null even though the node exists.

When I checked PartManager’s properties I came across UnloadingClearsPartManager property. Setting its value to false solved the problem. But, even when the diagram is not used it consumes the memory (which is not the case when UnloadingClearsPartManager is set to true). I tried using PartManager.RebuildNodeElements() in OnLoaded event handler of the diagram; but the problem still exists. How do I solve the issue with UnloadingClearsPartManager set to true?

And the other thing is, I want to disable animation in the Palette. The scenario is the palette is loaded with different nodes based on the node selected in the diagram. Whenever there is a change in the palette it animates (on few occasions scrollbars appear & disappear). I want the palette change to be quick without any animation. I’m using the below XAML snippet to disable animation which is not working:

<go:Palette Name="NodePalette" Height="50" Margin="0,0,3,0" ScrollViewer.VerticalScrollBarVisibility="Hidden" 
            NodeTemplateDictionary="{StaticResource NodePaletteCategoryTemplates}"  MaximumSelectionCount="1" 
            VerticalContentAlignment="Center" Padding="5,3">
    <go:Palette.LayoutManager>
        <go:LayoutManager Animated="False" AnimationTime="0"  />  
    </go:Palette.LayoutManager>
</go:Palette>

I’m using GoSilverlight 1.2.6.4 with Silverlight 4.

Thanks Smile

You probably don’t want to call RebuildNodeElements because we do that automatically for you – you’re just discarding all of the Nodes and Links and creating the same things all over again.

I’m not sure exactly what you are doing, but I suspect the problem is that you are looking for a Node too soon. The Node hasn’t been created yet. (There’s a lot of asynchrony in any WPF or Silverlight application.)

So whatever you are doing in a Loaded event handler, do it in a method that is called “later”. Maybe something like:
myDiagram.Loaded += (s, e) => { myDiagram.Dispatcher.BeginInvoke(() => { … }) };
I hope this will be sufficient.

I have answered your second question in a separate topic that I split off from this topic.

Thanks Walter.

Actually, the problem was, in diagram’s Loaded event handler I was adding event handlers for ModelChanged, ExternalObjectDropped & SelectionChanged events. Whenever I switched tab & returned to diagram’s tab, the event handlers were added every time. Thereby, whenever I added new node (based on the type of node, extra nodes are added which are linked to the new node), there were more nodes added than expected. Extra nodes were equal to the amount of time switched the tab & returned.

Solved the issue by removing the event handlers in the diagram’s UnLoaded event handler.