Display multiple graphs (with zoom-control) on one WPF-window

Mar 25, 2010 at 11:06 AM

Hi guys,

first of all I'd like to thank you for creating this great library. Very well done!

I want to display two graphs on one WPF-Window.

When I try to add one zoomcontrol with a graphlayout to each of the two gridcolumns, I receive to following errormessage: "EqualityToBooleanConverter: It's false, I won't bind back."

Has anyone a suggestion to me on how to fix this?

Regards,

Florian

 

Below is the XAML-Code its code-behind.

----------------------- XAML ----------------------------------

<Window x:Class="LeistungsregelnAbhängigkeitsgraph.Window1"
    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:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
    Title="Window1" Height="569.06" Width="883.581" x:Name="root" Loaded="root_Loaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="442.944*" />
            <ColumnDefinition Width="418.637*" />
        </Grid.ColumnDefinitions>

            <zoom:ZoomControl Name="zoom1" Grid.Column="0">
                

                <graphsharp:GraphLayout x:Name="graphLayoutLeistungAusschluss"
                                LayoutAlgorithmType="FR"
                                OverlapRemovalAlgorithmType="FSA"
                                HighlightAlgorithmType="Simple"
                                Grid.Column="0"
                                />
            </zoom:ZoomControl>
            <zoom:ZoomControl Name="zoom2" Grid.Column="1" >
                <graphsharp:GraphLayout x:Name="graphLayoutLeistungEinschluss"
                                LayoutAlgorithmType="FR"
                                OverlapRemovalAlgorithmType="FSA"
                                HighlightAlgorithmType="Simple"
                                Grid.Column="1"
                                />
            </zoom:ZoomControl>
    </Grid>
</Window>


----------------------- Code-Behind ----------------------------------

using System.Collections.Generic;
using System.Windows;
using QuickGraph;
using System.Data;
using System.Data.SqlClient;
using LeistungsregelnAbhängigkeitsgraph.Properties;
using System;

namespace LeistungsregelnAbhängigkeitsgraph
{
  /// <summary>
  /// Interaktionslogik für Window1.xaml
  /// </summary>
  public partial class Window1 : Window
  {
    private IBidirectionalGraph<object, IEdge<object>> _graphToVisualize;
    private IBidirectionalGraph<object, IEdge<object>> _graphToVisualize2;

    public Window1()
    {
      CreateGraphToVisualize();
      InitializeComponent();
      
    }

    private void CreateGraphToVisualize()
    {
        List<string> vertices = new List<string>();
        for (int i = 0; i < 5; i++)
        {
          vertices.Add(i.ToString());
          graph.AddVertex(vertices[i]);
        }

        //add some edges to the graph
        graph.AddEdge(new Edge<object>(vertices[0], vertices[1]));
        graph.AddEdge(new Edge<object>(vertices[1], vertices[2]));
        graph.AddEdge(new Edge<object>(vertices[2], vertices[3]));
        graph.AddEdge(new Edge<object>(vertices[3], vertices[1]));
        graph.AddEdge(new Edge<object>(vertices[1], vertices[4]));

        _graphToVisualize = graph;

        var graph1 = new BidirectionalGraph<object, IEdge<object>>();
        graph1.AddVertex(1);
        graph1.AddVertex(2);
        graph1.AddVertex(3);

        graph1.AddEdge(new Edge<object>(1, 2));
        graph1.AddEdge(new Edge<object>(2, 1));
        graph1.AddEdge(new Edge<object>(2, 3));
        graph1.AddEdge(new Edge<object>(3, 1));

        _graphToVisualize2 = graph1;
    }

    public IBidirectionalGraph<object, IEdge<object>> GraphToVisualizeLeistungEinschluss
    {
      get { return _graphToVisualize; }
    }

    public IBidirectionalGraph<object, IEdge<object>> GraphToVisualizeLeistungAusschluss
    {
      get { return _graphToVisualize2; }
    }

    private void root_Loaded(object sender, RoutedEventArgs e)
    {
      graphLayoutLeistungAusschluss.Graph = GraphToVisualizeLeistungAusschluss;
      graphLayoutLeistungEinschluss.Graph = GraphToVisualizeLeistungEinschluss;
    }
  }
}

 

 

 

 

Dec 8, 2010 at 8:49 AM

Hey, I'm also getting the same problem - did you find a fix?

Dec 8, 2010 at 8:57 AM
No, but I didn't continue searching for a solution. Sorry
May 26, 2011 at 2:05 PM
Edited May 30, 2011 at 9:35 AM

Hello,

this problem is caused by an error in WPFExtension converter

(to be precise: in WPFExtensions.Converters.BoolToVisibilityConverter.ConvertBack )

You could either try to fix this error or replace this function with another one you'd like more - or try to combine both graps in one layout with:

 

AddVertexRange()
AddEdgeRange()

and then show the whole new graph.

Aug 9, 2011 at 4:11 AM

Hi

 

I also had this problem. Jurisk is right, you need to modefy this function. Here is a thread how to do it.

http://stackoverflow.com/questions/6458067/how-to-set-wpfextensions-zoomcontrol-default-zoom

Hope this fixes the problem.