# ObservableGraphSourceBase

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](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-graphsourcebase) class and it also implements the [IObservableGraphSource](http://www.telerik.com/help/wpf/t_telerik_windows_diagrams_core_iobservablegraphsource.html) 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](https://www.telerik.com/products/wpf/documentation/assets/1037ecd0f300c2c1b2481f8472186e35/raddiagram-data-observablegraphsource.png)

> tip 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>](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-serializablegraphsource) 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

| 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\<TNode, TLink>** 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

* [ItemViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-itemviewmodels)
* [NodeViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-nodeviewmodel)
* [LinkViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-linkviewmodel)
* [ContainerNodeViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-containernodeviewmodel)
* [HierarchicalNodeViewModel](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-hierarchicalnodeviewmodel)
* [GraphSourceBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-graphsourcebase)
* [SerializableGraphSourceBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-serializablegraphsource)
