# Declaratively

This tutorial will walk you through the common task of populating **RadDiagram** with Diagramming items declaratively.

> Please note that the examples in this tutorial are showcasing Telerik Windows8 theme. In the [Setting a Theme](http://www.telerik.com/help/wpf/common-styling-apperance-setting-theme-wpf.html#Setting_Application-Wide_Built-In_Theme_in_the_Code-Behind) article you can find more information on how to set an application-wide theme.

Here is a regular **RadDiagram** declaration without any Diagramming items:

```XAML
<Grid>
    <telerik:RadDiagram />
</Grid>
```

Once you declare the **RadDiagram** your Diagramming drawing canvas is ready and you can add items in it. The basic items that are used in the Graph Object Model are the **RadDiagramConnection** and **RadDiagramShape**. You can add them to the **RadDiagram** declaration in order to create your own Diagramming structure.

### Add Shapes

When you create your Diagramming structure in XAML, it is important to keep in mind that by default the **RadDiagramShape** is positioned at the top left corner of the **RadDiagram**. This is why you'll need to set the **Position** property of each shape based on your layout requirements. The **Position** property gets or sets the coordinates of the top left point of the shape. You can find more information about the **RadDiagramShape** properties in the [Diagram Shapes](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/shape/raddiagrams-features-shapes) tutorial.

```XAML
<Grid>
    <telerik:RadDiagram>
        <telerik:RadDiagramShape x:Name="Shape1"
                                 Content="Shape 1"
                                 Position="80,20" />
        <telerik:RadDiagramShape x:Name="Shape2"
                                 Content="Shape 2"
                                 Position="320,20" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram data declaratively shapes](https://www.telerik.com/products/wpf/documentation/assets/d244de937223a4d768c9a140b1f44bcf/raddiagram_data_declaratively_shapes.png)

> Please note that the **RadDiagramShape** declarations set the **x:Name** of the shapes. You'll need the name of the shapes when attaching a connection to them.

### Add Connections

When you define the **RadDiagramConenctions** you will need to define the start and end points of the connection. Otherwise the connection will be displayed as a small point at the top left corner of the drawing canvas. You can define the start point either by setting the **Source** of the connection or by setting its **StartPoint** property. Alternatively the end point is defined through the **Target** or **EndPoint** properties. For more information about the **RadDiagramConnection** properties, please refer to the [Diagram Connections](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/raddiagrams-features-connections) tutorial.

```XAML
<Grid>
    <telerik:RadDiagram>
        <telerik:RadDiagramShape x:Name="Shape1_2"
                                 Content="Shape 1"
                                 Position="80,20" />
        <telerik:RadDiagramShape x:Name="Shape2_2"
                                 Content="Shape 2"
                                 Position="320,20" />

        <telerik:RadDiagramConnection SourceCapType="Arrow6Filled"
                                      Target="{Binding ElementName=Shape1_2}"
                                      TargetCapType="Arrow1Filled"
                                      StartPoint="5,40" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=Shape1_2}"
                                      SourceCapType="Arrow5"
                                      Target="{Binding ElementName=Shape2_2}"
                                      TargetCapType="Arrow5Filled" />
        <telerik:RadDiagramConnection Source="{Binding ElementName=Shape2_2}"
                                      SourceCapType="Arrow6"
                                      TargetCapType="Arrow6Filled"
                                      EndPoint="480,40" />
    </telerik:RadDiagram>
</Grid>
```

![Rad Diagram data declaratively conenctions](https://www.telerik.com/products/wpf/documentation/assets/665629fcaa9da9c64aead2217b38b9f9/raddiagram_data_declaratively_connections.png)

## See Also

* [Structure](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/structure)
* [Getting Started](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/getting-started)
* [DataBinding](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/populating-with-data/data-databinding)
* [Populating with Data in Code-Behind](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/populating-with-data/data-code-behind)
* [Shapes](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/shape/raddiagrams-features-shapes)
* [Connections](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagram-items/raddiagrams-features-connections)
* [Removing Items](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/items-manipulation/raddiagrams-features-delete)
