Version

Configuring the Visible Portion of the Diagram (xamDiagram)

Topic Overview

Purpose

This topic explains how to configure the visible portion of the xamDiagram™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic provides a conceptual overview of the xamDiagram control and its main features and capabilities.

This topic explains how to add the xamDiagram control to a WPF application.

Introduction

Configuring the visible portion of the diagram summary

The xamDiagram control exposes a set of properties for obtaining which is the currently visible part. The xamDiagram uses a concept of three rectangles whose position and size determine the currently visible part. Each of these rectangles is exposed as a property of the XamDiagram class.

The ViewportRect denotes the currently available space in the control. Margins, paddings of the control set aside, and the ViewportRect will have exactly the same size as the xamDiagram .

The WorldRect denotes the area in which there are diagram nodes and connections, that is the rectangle representing the union of all the bound rectangles of the diagram items.

The WindowRect determines what part of the WorldRect to display in the ViewportRect.

Configuring the visible portion of the diagram summary chart

The following table briefly explains the configurable aspects of the xamDiagram related to controlling which is the visible portion of it.

Configurable aspect Details Properties

Visible portion of the diagram

Control the zoom level and which items are currently in view.

Configuring the Visible Portion of the Diagram

Overview

Configuring what part of the diagram is currently visible is done by setting the WindowRect property to a Rect object with the desired position and size. This sets both the zoom level as well as the vertical and horizontal pan positions. Setting a WindowRect with smaller size results in greater zoom level and consequently smaller visible portion of the diagram. Moving the diagram to the left is done by increasing the value of the X position of the WindowRect. Decreasing this value moves the visible portion of the diagram to the right. Similarly the Y position of the WindowRect controls the vertical scroll position of the diagram.

As a shorthand for setting just the zoom level, the ZoomLevel property can be used.

Additionally, the xamDiagram exposes ZoomTo100 and ScaleToFit methods to reset the zoom level or make all items in the diagram visible.

Property settings

The following table maps the desired configuration to the property settings that manage it.

In order to: Use this property: And set it to:

Set what portion of the diagram is currently in view

The desired rect.

In the examples below, the Width and Height properties of the xamDiagram are set in order to have a fixed ViewportRect of (0,0,500,300) and the two nodes are positioned so that the WorldRect is (0,0,320,280).

Example – default setting

The screenshot below demonstrates how two nodes in the xamDiagram would look as a result of the following settings:

Property Value

0,0,500,300

xamDiagram Configuring The Visible Portion Of The Diagram 1.png

Example – zoom out

The screenshot below demonstrates two nodes in the xamDiagram would look as a result of the following settings:

Property Value

-250,-150,1000,600

xamDiagram Configuring The Visible Portion Of The Diagram 2.png

Example – pan right

The screenshot below demonstrates how two nodes in the xamDiagram would look as a result of the following settings:

Property Value

200,0,500,300

xamDiagram Configuring The Visible Portion Of The Diagram 3.png

Example – full code

The example code below shows how to perform the previous examples.

In XAML:

<ig:XamDiagram x:Name="Diagram"
               WindowRect="0,0,500,300"
               NavigationPaneVisibility="Visible"
               Width="502" Height="302" BorderThickness="1" BorderBrush="Black">
    <ig:DiagramNode Content="{Binding Bounds, RelativeSource={RelativeSource Self}}"/>
    <ig:DiagramNode Content="{Binding Bounds, RelativeSource={RelativeSource Self}}" Position="200,200"/>
</ig:XamDiagram>

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to control the size and position of the diagram nodes of the xamDiagram control.

This topic explains how to configure where the diagram connections start and end.