Custom Symbols

I can’t figure out the easiest way to add a pallet of custom symbols that can be dragged onto the diagram.

What I’m trying to accomplish is add a group of symbols like these:

A cable-break symbol:

and a measurement tool with a textblock where a user can type a measurement:

I’ve tried various methods based on the samples but I literally don’t need these symbols to do anything other than be dragged onto the diagram surface. They don’t need links or attributes.

How can I very simply add a custom defined path ‘figure’ to a pallet?
I tried the following but the path isn’t showing up and I’m not even sure that what I’m trying to do is possible:

<span ="Apple-tab-span" style="white-space:pre">	</span><go:DataTemplateDictionary x:Key="NodeTemplateDictionary" />


        <DataTemplate x:Key="MiscFigureTemplate">
            <StackPanel go:Part.SelectionElementName="Shape"
                    go:Part.SelectionAdorned="True"
                    go:Node.Rotatable="True"
                    go:Node.Resizable="True"
                    go:Node.LocationElementName="Shape">
                <TextBlock Style="{StaticResource TextBlockStyle}"
                     Text="{Binding Path=Data.Text, Mode=TwoWay}"
                     HorizontalAlignment="Center" VerticalAlignment="Center" />
                <go:NodePanel x:Name="Shape"
                        HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Path Stroke="Black" StrokeThickness="{Binding Path=Data.PathStrokeThickness, Mode=TwoWay}" Stretch="Fill" 
                          Data="{Binding Path=Data.PathData, Mode=TwoWay}"
                          go:Node.PortId="" Cursor="Hand"
                          go:Node.LinkableFrom="False" go:Node.LinkableTo="False">
                    </Path>
                </go:NodePanel>
            </StackPanel>
        </DataTemplate>

...........


<go:Palette Grid.Row="0" x:Name="pMisc" NodeTemplate="{StaticResource PaletteNodeTemplate}" Template="{StaticResource DiagramTemplate}" MinHeight="100" Margin="15,20,0,0">
<go:Palette.LayoutManager>
    <go:LayoutManager Animated="False" AnimationTime="0"  />
</go:Palette.LayoutManager>
<go:Palette.Layout>
    <golayout:GridLayout Sorting="Forward" CellSize="10 10" Spacing="25 25" />
</go:Palette.Layout>
</go:Palette>
DataTemplateDictionary dtd = Diagram.FindResource<DataTemplateDictionary>(this, "NodeTemplateDictionary");
dtd.Add("MiscFigureTemplate", Diagram.FindResource<DataTemplate>(this, "MiscFigureTemplate"));

..............


//Misc
var mpmodel = new GraphModel<MiscNode, String>();
mpmodel.NodesSource = new List<MiscNode>() {
<span ="Apple-tab-span" style="white-space:pre">	</span>new MiscNode() { Category="MiscFigureTemplate", Key="MeasurementTool", PathData="M130.5,0.5 L130.5,30.5 M0.5,15.5 L130.5,15.5 M0.5,30.5 L0.5,0.5", PathStrokeThickness="2"
<span ="Apple-tab-span" style="white-space:pre">	</span>},
};
mpmodel.Modifiable = true;
pMisc.TemplateApplied += (s, e) => { pMisc.Panel.ZoomTime = 0; };
pMisc.Model = mpmodel;

.............


    public class MiscNode : GraphModelNodeData<String>
    {
        public string PathData { get; set; }
        public string PathStrokeThickness { get; set; }
    }

As a general debugging suggestion, I’ll say that you might want to check the trace listener output (i.e. VS Output window) for any data-binding errors or other problems.

Also, you could try replacing your Path with a trivial Ellipse of fixed size and fill, just to see if your Palette is being populated or not.

Is this in Silverlight?
I suspect that the problem is that you are data-binding the Path.Data property, which is of type Geometry, to your MiscNode.PathData property, which is a string, and Silverlight is not automatically converting the string to a Geometry.

You’ll need to define a Converter that does that.

But instead it might be easier to define one DataTemplate for each kind of Path.
That way XAML parser can be responsible for creating the Path and its Geometry.

On a separate matter, although you can certainly implement the “measurement” as a static set of elements, you really want the behavior that I believe you imply by being able to modify the text.
That is do-able, but requires some programming. Alas, I don’t have time right now to do this for you.