here is the solution. You must create a custom edge type and save the color information in the edge object itself or create a converter that can calculate the color from the edge object.
In addition, you must configure EdgeControl with Style .
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using GraphSharp; using QuickGraph; using GraphSharp.Controls; namespace WpfApplication1 {
XAML:
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls" xmlns:my="clr-namespace:WpfApplication1" Title="MainWindow" Height="350" Width="525" Name="root"> <Grid> <Grid.Resources> <my:EdgeColorConverter x:Key="edgeToEdgeColorConverter"/> <Style TargetType="{x:Type graphsharp:EdgeControl}"> <Style.Setters> <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource Self},Path=Edge.EdgeColor,Converter={StaticResource edgeToEdgeColorConverter}}"/> </Style.Setters> </Style> </Grid.Resources> <graphsharp:GraphLayout x:Name="graphLayout" Graph="{Binding ElementName=root,Path=Graph}" OverlapRemovalAlgorithmType="FSA" HighlightAlgorithmType="Simple" LayoutAlgorithmType="FR"/> </Grid> </Window>
source share