New to Telerik UI for WPFStart a free 30-day trial

ObservableGraphSourceBase

Updated over 6 months ago

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

This article describes the ObservableGraphSourceBase<TNode, TLink> class defined in the Diagramming Extensions.

Overview

The ObservableGraphSourceBase<TNode, TLink> 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<TNode, TLink> 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<TNode, TLink> or from a class inheriting the ObservableGraphSourceBase<TNode, TLink> class (for instance the SerializableGraphSourceBase<TNode, TLink> class). Only then the drag/drop operations will be reflected in your ViewModels.

Inherited Properties

The ObservableGraphSourceBase<TNode, TLink> class exposes all properties it inherits from the GraphSourceBase class:

Inherited Properties

NameDescription
InternalItemsGets the internal ObservableCollection of business nodes.
InternalLinksGets the internal ObservableCollection of business links.
ItemsGets an IEnumerable collection of business nodes.
LinksGets an IEnumerable collection of business links.

Methods

The ObservableGraphSourceBase<TNode, TLink> class exposes the following virtual methods:

Virtual Methods

NameDescription
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

NameDescription
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.
ClearRemoves 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