New to Telerik UI for WPF? Download free 30-day trial

ObservableGraphSourceBase

Telerik Diagramming Framework provides a list of ViewModels defined in the Telerik.Windows.Controls.Diagrams.Extensions.dll.

This article describes the ObservableGraphSourceBase class defined in the Diagramming Extensions.

Overview

The ObservableGraphSourceBase derives from the GraphSourceBase class and it also implements the IObservableGraphSource interface. Its main purpose is to provide an out-of-the-box ViewModel implementation that supports TwoWay binding to the RadDiagram GraphSource property.

ObservableGraphSourceBase Inheritance Model raddiagram-data-observablegraphsource

If you need to define a data-bound RadDiagram that has to support drag and drop of items, then you need to make sure that your custom GraphSource implementation derives from the ObservableGraphSourceBase or from a class inheriting the ObservableGraphSourceBase class (for instance the SerializableGraphSourceBase class). Only then the drag/drop operations will be reflected in your ViewModels.

Inherited Properties

The ObservableGraphSourceBase class exposes all properties it inherits from the GraphSourceBase class:

Inherited Properties

Name Description
InternalItems Gets the internal ObservableCollection of business nodes.
InternalLinks Gets the internal ObservableCollection of business links.
Items Gets an IEnumerable collection of business nodes.
Links Gets an IEnumerable collection of business links.

Methods

The ObservableGraphSourceBase class exposes the following virtual methods:

Virtual Methods

Name Description
CreateLink(object source, object target) Creates a new ILink object associated with the specified source and target nodes.
CreateNode(IShape shape) Creates a new instance of the TNode type. And as it receives an IShape object, when you override it, you can use the IShape argument to create a TNode instance associated with the specified shape.

Inherited Virtual Methods

Name Description
AddNode(TNode) Adds a specified business node to the InternalItems collection.
AddLink(TLink) Adds a specified business link to the InternalLinks collection.
RemoveLink(TLink) Removes a specified business link from the InternalLinks collection and returns a boolean value indicating whether the operation was successful.
RemoveItem(TNode) Removes a specified business node from the InternalItems collection and returns a boolean value indicating whether the operation was successful.
Clear Removes all nodes and links from the InternalItems and InternalLinks collections.

Please note that in your solution it is best to create a custom class deriving from ObservableGraphSourceBase. Once you do so, you will be able to override all of the above virtual methods. This will allow you to describe a custom RadDiagram GraphSource class that supports TwoWay binding scenarios where any changes in the RadDiagram UI are reflected in your GraphSource implementation.

See Also

In this article