方法或操作未实现绑定错误

编程入门 行业动态 更新时间:2024-10-26 09:34:28
本文介绍了方法或操作未实现绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在开发一个Visual Studio插件(VSPackage),最终应该能够可视化通话关系。为了表示它们,我想使用管理图形的图#库(避免重叠边等)。 不幸的是,我的XAML中的运行时收到以下错误消息:

XamlParseException:方法或操作未实现 / p>

错误在< graph上弹出:CallRelationGraphLayout Graph ={Binding RelationGraph}/> 。

< UserControl x:Class =Biocoder.InteractiveExploration.View.ExplorationControl xmlns =schemas.microsoft/winfx/2006/xaml/presentation xmlns:x =schemas.microsoft/winfx/2006/xaml xmlns:mc =schemas.openxmlformats/markup-compatibility/2006 xmlns:d =schemas.microsoft/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.Inte ractiveExploration.Graph xmlns:viewmodels =clr-namespace:Biocoder.InteractiveExploration.ViewModel xmlns:controls =clr-namespace:Biocoder.InteractiveExploration.Controlsmc:Ignorable =dd:DesignHeight =300d: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背景=黄色> < graph:CallRelationGraphLayout Graph ={Binding RelationGraph}/> < / zoom:ZoomControl> < / Grid> < / UserControl>

我还创建了自己的顶点,边和图布局类。我的图表应该最终表示方法(顶点)之间的调用关系(边)。

MethodVertex.cs

public class MethodVertex { public string ID {get;私人集合} public bool IsMale {get;私人集合 public MethodVertex(string id,bool isMale) { ID = id; IsMale = isMale; public override string ToString() { return string.Format({0} - {1},ID,IsMale); } }

RelationEdge.cs / p>

public class RelationEdge:Edge< MethodVertex> { public string Id {get;私人集合 public RelationEdge(string id,MethodVertex source,MethodVertex target):base(source,target) { Id = id; } }

CallRelationGraphLayout.cs / p>

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) {} } pre>

在 ExplorationToolViewModel 中,我声明了RelationGraph如下:

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)); }

我也许应该提到的是我有时会显示以下错误,项目编译运行。

GenericArguments [1],'Biocoder.InteractiveExploration.Graph.RelationEdge',on'GraphSharp.Algorithms.Layout.ILayoutAlgorithm`3 [TVertex,TEdge,TGraph ]违反了类型TEdge的约束。

也许是它的问题的根源,但是我从来没有忽略它,因为它编译和我做了对应于此教程。

奇怪的是,它实际上在使用Graph#提供的DLL的正常WPF应用程序中工作。当我离开Graph-property时,错误不会显示出来,所以我猜想它与Graph属性有关。任何关于如何解决这个问题的提示?

非常感谢您提前!

解决方案

当在VSPackage中使用Graph#时,我遇到了同样的问题。我通过不使用Bindings的图表来克服这个问题,但是通过在CodeBehind中分配 Graph 属性。

这导致一个例外,当分配图表属性。我怀疑其原因是在GraphSharp.Controls中,程序集在XAML中使用,但在编译时不会添加引用,因为代码中没有引用。在分配 var a = System.Reflection.Assembly.Load(WPFExtensions,Version = 1.0.3437.34043,Culture = neutral,PublicKeyToken = null);

此行加载WPFExtensions库,然后WPF根据XAML中的引用尝试加载它。之后,显示了图表。

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="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" xmlns:mc="schemas.openxmlformats/markup-compatibility/2006" xmlns:d="schemas.microsoft/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!

解决方案

I've experienced the same issue when using Graph# in a VSPackage. I was able to overcome the issue by not using Bindings for the graph, but by assigning the Graph property in CodeBehind.

This led to an exception that the WPFExtensions assembly could not be loaded when assigning the Graph property. I suspect that the reason for that is that in GraphSharp.Controls, the assembly is used in XAML, but the reference is not added when compiling as there are no references in code. I was able to fix this by adding the following line before assigning the Graph property:

var a = System.Reflection.Assembly.Load("WPFExtensions, Version=1.0.3437.34043, Culture=neutral, PublicKeyToken=null");

This line loads the WPFExtensions library before WPF tries to load it based on the reference in the XAML. Afterwards, the graph was shown.

更多推荐

方法或操作未实现绑定错误

本文发布于:2023-11-14 19:08:41,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   错误   操作   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!