Zoom resize issue in NodeXL for WPF

Sep 22, 2010 at 6:17 PM

I am working on a WPF application using NodeXL, and I've encountered the problem in this post where a graph expands beyond its bounds upon resizing (http://nodexl.codeplex.com/Thread/View.aspx?ThreadId=212978). 

Since that response was from a few months ago I was wondering if anyone has found any other solutions to this problem.  In my implementation I am trying to place the NodeXL control into a WPF UserControl, which could be moved around or even resized by the user inside a larger window.  So for me, trying to cover up the expanded portions of the graph with a dock panel would be difficult since it's position and size change dynamically. 

I would appreciate any suggestions that others have for this issue.



Sep 23, 2010 at 2:20 PM

After doing some more digging, I've figured out a usable solution to this problem which I will post here for reference. 

The problem is that the Graph object does need to be larger than the size it started at in order for you to zoom in.  However, we only want to see a portion of that zoomed in image at a time, corresponding to the initial size of the Graph.  To do this in WPF we can use clipping (see http://www.alksolutions.com/en/Blog/Can-Balioglu/Clipping-in-WPF for a good explanation) on a container object that holds the NodeXL control.  Grids work well for this, as do a few other Panel-type classes (Border, Canvas, etc).  The XAML should look like this:

<Grid x:Name="ClipGrid" Width="500" Height="500" ClipToBounds="True">
     <my:NodeXLControl  Name="theNXLcontrol" Width="500" Height="500" />

Setting the ClipToBounds property on the Grid gives the exact behavior we want - the Graph can still zoom in and expand, but the visible Graph is clipped by the dimensions set in ClipGrid.

Hopefully this will be helpful to others who have had the same issue.




Sep 23, 2010 at 4:56 PM

Thank you, Amana!

-- Tony