Click here to Skip to main content
15,896,063 members
Articles / Desktop Programming / WPF

Using WPF to Visualize a Graph with Circular Dependencies

Rate me:
Please Sign up or sign in to vote.
4.98/5 (52 votes)
15 Nov 2009CPOL7 min read 170.8K   4K   139  
Reviews a WPF application that displays an object graph which can be rearranged by the user at runtime, and highlights circular dependencies in its nodes.
<Window 
  x:Class="CircularDependencyTool.AppWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:CircularDependencyTool"
  Icon="app.ico"
  ResizeMode="NoResize"
  Title="Circular Dependency Visualizer" 
  Width="1100" Height="750" 
  WindowStartupLocation="CenterScreen"
  >

  <Window.DataContext>
    <ObjectDataProvider 
      ObjectType="{x:Type local:GraphBuilder}" 
      MethodName="BuildGraphs" 
      />
  </Window.DataContext>

  <Window.Resources>
    <Style TargetType="{x:Type local:NodeConnector}">
      <Setter Property="ArrowLength" Value="12" />
      <Setter Property="Stroke" Value="Gray" />
      <Setter Property="StrokeThickness" Value="3" />
      <Style.Triggers>
        <Trigger Property="IsPartOfCircularDependency" Value="True">
          <Setter Property="Stroke" Value="DarkRed" />
        </Trigger>
      </Style.Triggers>
    </Style>
  </Window.Resources>

  <!-- List of Graphs -->
  <ItemsControl 
    HorizontalAlignment="Center"
    ItemsSource="{Binding Path=., Mode=OneTime}"
    VerticalAlignment="Center"
    >
    <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
        <WrapPanel />
      </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
      <DataTemplate>
        <local:GraphWithDetailsView />
      </DataTemplate>
    </ItemsControl.ItemTemplate>
  </ItemsControl>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Josh creates software, for iOS and Windows.

He works at Black Pixel as a Senior Developer.

Read his iOS Programming for .NET Developers[^] book to learn how to write iPhone and iPad apps by leveraging your existing .NET skills.

Use his Master WPF[^] app on your iPhone to sharpen your WPF skills on the go.

Check out his Advanced MVVM[^] book.

Visit his WPF blog[^] or stop by his iOS blog[^].

See his website Josh Smith Digital[^].

Comments and Discussions