I'm currently developing a Visual Studio plugin (VSPackage) which finally should be able to visualize call relations. In order to represent them I want to use the Graph# library which manages the graph (avoiding overlapping edges etc.). Unfortunately I get the following error message at runtime in my XAML:
XamlParseException: The method or operation is not implemented.
The error pops up on the <graph:CallRelationGraphLayout Graph="{Binding RelationGraph}"/>
tag.
<UserControl x:Class="Biocoder.InteractiveExploration.View.ExplorationControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
xmlns:graph="clr-namespace:Biocoder.InteractiveExploration.Graph"
xmlns:viewmodels="clr-namespace:Biocoder.InteractiveExploration.ViewModel"
xmlns:controls="clr-namespace:Biocoder.InteractiveExploration.Controls" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.DataContext>
<viewmodels:ExplorationToolViewModel/>
</UserControl.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<zoom:ZoomControl Grid.Row="1"
Zoom="0.2"
ZoomBoxOpacity="0.5"
Background="Yellow">
<graph:CallRelationGraphLayout Graph="{Binding RelationGraph}"/>
</zoom:ZoomControl>
</Grid>
</UserControl>
I also created own vertex, edge and graph layout classes. My graph should finally represent call relations (edges) between methods (vertices).
MethodVertex.cs
public class MethodVertex
{
public string ID { get; private set; }
public bool IsMale { get; private set; }
public MethodVertex(string id, bool isMale)
{
ID = id;
IsMale = isMale;
}
public override string ToString()
{
return string.Format("{0}-{1}", ID, IsMale);
}
}
RelationEdge.cs
public class RelationEdge : Edge<MethodVertex>
{
public string Id { get; private set; }
public RelationEdge(string id, MethodVertex source, MethodVertex target)
: base(source, target)
{
Id = id;
}
}
CallRelationGraphLayout.cs
public class CallRelationGraphLayout : GraphLayout<MethodVertex, RelationEdge, CallRelationGraph>
{}
CallRelationGraph.cs
public class CallRelationGraph : BidirectionalGraph<MethodVertex, RelationEdge>
{
public CallRelationGraph()
{}
public CallRelationGraph(bool allowParallelEdges)
: base(allowParallelEdges)
{ }
public CallRelationGraph(bool allowParallelEdges, int vertexCapacity)
: base(allowParallelEdges, vertexCapacity)
{}
}
In the ExplorationToolViewModel I declared the RelationGraph as follows:
private CallRelationGraph _relationGraph;
public CallRelationGraph RelationGraph
{
get { return _relationGraph; }
set
{
if (value != _relationGraph)
{
_relationGraph = value;
NotifyPropertyChanged("RelationGraph");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
What I maybe also should mention is that I have the following error displayed sometimes but the project compiles and runs.
GenericArguments[1 ], 'Biocoder.InteractiveExploration.Graph.RelationEdge', on 'GraphSharp.Algorithms.Layout.ILayoutAlgorithm`3[TVertex,TEdge,TGraph]' violates the constraint of type 'TEdge'.
Maybe its the source of the problem but I ignored it so far since it compiled and I did it corresponding to this tutorial.
The strange thing is that it actually works in a normal WPF application using the DLLs provided by Graph#. When I leave the Graph-property out the error doesn't show up so I guess it has to do with the Graph property. Any hints about how to solve this?
Thank you very much in advance!
NotImplementedException
sure doesn't help much! I've written up a guide on how to diagnose the underlying problem at https://mcmap.net/q/1010542/-notimplementedexception-when-loading-xaml-via-system-windows-application-loadcomponent. – Deflocculate