Pallete showing nodes with non-desired Links

I used the pallete and defined node template to be used by it. But it displays nodes with there links inside the pallete. I don’t want these links. I just want nodes. Here is the screen shot:

Here is the code:

<go:Palette x:Name=“myPalette” Grid.Row=“1” AllowDelete=“False” AllowDrop=“False” AllowEdit=“False” AllowGroup=“False” AllowLink=“False” AllowPrint=“False” AllowMove=“False” GridSnapEnabled=“True” BorderThickness=“0” Padding=“5” HorizontalContentAlignment=“Left” VerticalContentAlignment=“Top” NodeTemplate="{StaticResource NodeTemplate}" VerticalAlignment=“Stretch”/>


You must have included link information in the palette’s model.
The palette is just using the default template for Links.
It’s good that you see the links, so that you know that you should clean up that model.

If you are using a GraphLinksModel, it means you have added link data to the LinksSource collection.
If you are using a GraphModel or a TreeModel, it means that there are references in the node data to other node data.

Yes it has references. Actually I used the same model for Pallete too which i am already using for Diagram.
var model = new UnitTreeModel<UnitMember, int>();
The model UnitTreeModel loads XML data for me and intializes it into its NodeSource. Just tell me if I got you right - now I have to create a separate model for Pallete so that there’s no such relationships between Nodes available on pallete.

You definitely have to use a different model if you want to show different things.

Each Diagram (including Palettes) starts off with its own model.
If you replace it, that’s good, but this is a situation where you do not want to share models.

You would want to share models only when you want two views on the same information.
But two Diagrams sharing a model can still have drastically different appearances, because you can use different templates.
See the UpdateDemo for an example of this.

On the other hand, I suppose in this kind of situation, where the palette is read-only, it is possible to share models if you changed the Palette.LinkTemplate to be an empty DataTemplate.
And the NodeTemplate cannot modify the model data with a TwoWay data-binding.

(Actually, if you are using Silverlight, I think Silverlight did not permit empty templates – you would need to use a trivial element that has no appearance. I haven’t tried it with Silverlight 4 or 5.)

Hi,

Thanks a lot for your reply. I will check if we are allowed to define an empty template in silverlight 4 or not. I think it will work.

Now one more thing I would like to know. What I want is a different UI for nodes inside my Pallete (eg: A box with name under it) and when i drop it over Diagram, its UI should change to what a node’s template is (eg: some complex UI).

Plus I want to know if any node validation is available here. Like if am dropping a node of category Digit over some node A which is of category Alphabets. So when am dropping that node, the target node should validate the source node if it is allowed or not, or something like this. I hope you got what am trying to say. :)

That’s exactly why you would specify a different Palette.NodeTemplate than you would for your main Diagram.

Why don’t you ask about drag-and-drop validation in another topic? Are you using Silverlight or WPF?

Thanks a lot Mr. Walter!! :)

I achieved this. Problem was I was not defining the Key and ParentKey on my own, GoXaml was creating both on its own where Key value was starting with 0 and default ParentKey for nodes was taken 0 by all the nodes. Due to this all the other nodes were considering the node (whose key is 0) as its parent and as a result they were showing connectors.

Ah, yes, that’s because there’s no “null” value when the key type is “int”.

I’m glad you figured it out.