Group Templates

is it possible to generate predefined templates of for example two nodes (in my app a slider and a textbox) in a group and drag them from a Palette or a ListView?
It must be a group so the user can later ungroup and modify the separate nodes.

Sure, a Palette can have an item that is a Group. Although its template might be different from your target Diagram, it need not be, because what matters is the model data – whether there are member node data and member link data that belong to that item group data in the Palette’s Model.

You can even have the Group be collapsed in the Palette and then have it be expanded in the main Diagram, either by using a different template or by having a Diagram.ExternalObjectsDropped event handler that explicitly expanded the dropped Group(s).

It’s even possible for the ExternalObjectsDropped event handler explicitly ungroup what was dropped, so that the user never sees that there was a group ever in the diagram.

Hi Walter,
do you habe an example for such a template?
I habe no idea how to define such a remplate

It really isn’t any different than defining templates for diagrams, since Palette inherits from Diagram. What specifically are you asking about?

The question is: how to define a template with two or more nodes in a group?

Presumably you have defined both the Palette’s GroupTemplate(s) and NodeTemplate(s), and you set up the Palette’s model’s NodesSource to include an instance of the node data for the group and the node data for its members and the link data for any links between the members.

That is really exactly the same as setting up a Diagram showing a Group with some Nodes and Links inside of the group.

No I mean: how do I define a template in Xaml for that? And if I can do so, can the PartManager select such a template with I think it was the FindCategory Methode?

My first reaction was that we keep talking past each other. Then I realized that maybe you were asking about how to create instances of Nodes (including Groups and Links) in XAML.

It is possible to do that, as discussed in the GoXamIntro document: However, I do not believe that the user would be able to drag-and-drop from such a Diagram (including Palette) to another Diagram, because with the DraggingTool and Windows drag-and-drop the user is really copying data. Model data, not FrameworkElements.

Drag-and-drop and copy-and-paste need to work with model data, not FrameworkElements, so that it is meaningful to transfer data/information between Controls.

Instead, if you really want to define complete Palettes in XAML, I would do so by creating the model and its data in XAML, and assigning it to the palette. I think you can find examples of that (outside of the context of GoXam) on the web.