c# WPF Graph# layout using DataTemplate to show custom vertices causes XamlParseException
<p>I just recently started working with QuickGraph and Graph# to manage and display graphs of plugins and possible connexions between them.</p>

<p>Each plugin is represented by an object of Plugin class containing properties I would like to show, so i tried to use a DataTemplate for this class.</p>

<p>The problem is when the window in which the GraphLayout is is shown (during InitializeComponent), I get a XamlParseException apparently thrown by the ressource dictionary.</p>

<p>Exception details (sorry for french :P) :</p>

<pre><code>L'exception System.Windows.Markup.XamlParseException s'est produite   HResult=-2146233087   Message=La propriété Set 'System.Windows.ResourceDictionary.DeferrableContent' a levé une exception.   Source=PresentationFramework   LineNumber=0   LinePosition=0   StackTrace:
       à System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       à System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       à System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       à System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       à IHM.PluginsWindow.InitializeComponent() dans c:\SIMON\Ptiou\IHM\00-SRC\widget\PluginsWindow.xaml:ligne 1
       à IHM.PluginsWindow..ctor() dans C:\SIMON\Ptiou\IHM\00-SRC\widget\PluginsWindow.xaml.cs:ligne 35   InnerException: System.NotImplementedException
       HResult=-2147467263
       Message=La méthode ou l'opération n'est pas implémentée.
       Source=PresentationFramework
       StackTrace:
            à System.Windows.Baml2006.Baml2006SchemaContext.ResolveBamlType(BamlType bamlType, Int16 typeId)
            à System.Windows.Baml2006.Baml2006SchemaContext.GetXamlType(Int16 typeId)
            à System.Windows.Baml2006.Baml2006Reader.Process_ConstructorParameterType()
            à System.Windows.Baml2006.Baml2006Reader.Process_OneBamlRecord()
            à System.Windows.Baml2006.Baml2006Reader.ReadKeys()
            à System.Windows.ResourceDictionary.SetDeferrableContent(DeferrableContent deferrableContent)
            à System.Windows.Baml2006.WpfSharedBamlSchemaContext.&lt;&gt;c.&lt;Create_BamlProperty_ResourceDictionary_DeferrableContent&gt;b__297_0(Object target, Object value)
            à System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
            à MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
            à MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
       InnerException:
</code></pre>

<p>The problem must probably come from the DataTemplate i'm using because the Graph is showing fine without it (can't show any property of the objects though).
I also tried setting the graph by binding or from code behind and it didn't change anything.</p>

<p>XAML file where the GraphLayout and the DataTemplate are :</p>

<pre><code>&lt;Window x:Class="IHM.PluginsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpfextensions="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
        xmlns:datamodel="clr-namespace:DATAMODEL;assembly=DATAMODEL"
        xmlns:local="clr-namespace:IHM"
        Height="1080" Width="1920" Margin="0,0,0,0"
        Topmost="true" ResizeMode="NoResize" WindowStyle="None" ShowInTaskbar="False"   
        WindowStartupLocation="Manual"       
        VerticalAlignment="Top"
        HorizontalAlignment="Left"
        AllowsTransparency="True" Background="Transparent"
        WindowState="Normal"
        x:Name="root"&gt;


    &lt;Grid Name="containerGrid" Height="1080" Width="1920" Margin="0,0,0,0"&gt;
        &lt;Grid.Resources&gt;
            &lt;DataTemplate DataType="{x:Type datamodel:Plugin}"&gt;
                &lt;Border BorderThickness="3" CornerRadius="6" Padding="3" BorderBrush="Black"&gt;
                    &lt;Grid&gt;
                        &lt;TextBlock Text="{Binding name}"/&gt;
                    &lt;/Grid&gt;
                &lt;/Border&gt;
            &lt;/DataTemplate&gt;
        &lt;/Grid.Resources&gt;

        &lt;wpfextensions:ZoomControl&gt;
            &lt;local:MyGraphLayout
                x:Name="pluginGraphLayout"
                LayoutAlgorithmType="FR"
                OverlapRemovalAlgorithmType="FSA"
                HighlightAlgorithmType="Simple"&gt;
            &lt;/local:MyGraphLayout&gt;
        &lt;/wpfextensions:ZoomControl&gt;

    &lt;/Grid&gt;

&lt;/Window&gt;
</code></pre>

<p>CodeBehind :</p>

<pre><code>namespace IHM 
{
    public partial class PluginsWindow : Window, INotifyPropertyChanged
        {
            Point m_start;
            Vector m_startOffset;
            BidirectionalGraph&lt;Plugin, BBlink&gt; pluginGraph = new BidirectionalGraph&lt;Plugin, BBlink&gt;();

            List&lt;Plugin&gt; shownPlugins = new List&lt;Plugin&gt;();
            List&lt;BBlink&gt; shownLinks = new List&lt;BBlink&gt;();

            public PluginsWindow()
            {
                InitializeComponent();
                this.Background = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
            }

            public void MakeGraph(List&lt;BBlink&gt; links)
            {
                List&lt;Plugin&gt; plugins = new List&lt;Plugin&gt;();
                foreach(BBlink link in links)
                {
                    if(!plugins.Contains(link.startPlugin))
                        plugins.Add(link.startPlugin);
                    if(!plugins.Contains(link.endPlugin))
                        plugins.Add(link.endPlugin);
                }
                if(plugins.Count &lt; 1)
                    return;

                this.shownPlugins = plugins;
                this.shownLinks = links;
                this.showPathGrid();

                BidirectionalGraph&lt;Plugin, BBlink&gt; graph = new BidirectionalGraph&lt;Plugin,BBlink&gt;();
                foreach (Plugin plugin in plugins)
                    graph.AddVertex(plugin);

                foreach (BBlink link in links)
                    graph.AddEdge(link);

                this.pluginGraph = graph;
                this.pluginGraphLayout.Graph = graph;
            }

            protected void OnPropertyChanged(string propertyName)
            {
                var handle = PropertyChanged;
                if (handle != null)
                    handle(this, new PropertyChangedEventArgs(propertyName));
            }

            public event PropertyChangedEventHandler PropertyChanged;
        }

        public class MyGraphLayout : GraphSharp.Controls.GraphLayout&lt;Plugin, BBlink, IBidirectionalGraph&lt;Plugin, BBlink&gt;&gt;
        { /* nothing to do here... */ }
}
</code></pre>

<p>The total inexistance of a Graph# documentation didn't help at all so i tried following this <a href="https://graphsharp.codeplex.com/discussions/68634" rel="nofollow noreferrer">post</a> on their site but it looks identical to what i've done.</p>