# In Code-Behind

This tutorial will walk you through the common tasks of [adding](https://www.telerik.com/products/wpf/documentation/controls/radrating/populating-with-data/populating-in-code-behind#Adding-RadRatingItems) and [removing](https://www.telerik.com/products/wpf/documentation/controls/radrating/populating-with-data/populating-in-code-behind#Removing-RadRatingItems) **RadRatingItems** programmatically.

```XAML
<telerik:RadRating x:Name="radRating"/>
```

> caption Result from example 1

![RadRating](https://www.telerik.com/products/wpf/documentation/assets/a4b0259656e28adb889e5f6150286891/rating_default.png)

## Adding RadRatingItems

In order to add new rating items to a **RadRating** control, you have to perform several simple steps:

* Create an instance of the **RadRatingItem** class

* Set its properties such as **Content** if you need so

* Add it to the **RadRating**'s **Items** collection

  ```C#
  RadRatingItem ratingItem = new RadRatingItem();
  this.radRating.Items.Add(ratingItem);
  ```

  ```VB.NET
  		Dim ratingItem As New RadRatingItem()
  		Me.radRating.Items.Add(ratingItem)
  ```

> caption Result from example 2

![RadRating](https://www.telerik.com/products/wpf/documentation/assets/9f5dcde06b1d3167e925654b9139b970/rating_wit_6_items.png)

In order to clear the default rating items and add new you have to add one additional step to the previous:

* Clear the **Items** collection of the **RadRating** control

* Create an instance of the **RadRatingItem** class

* Set its properties such as **Content** if you need so

* Add it to the **RadRating**'s **Items** collection

```C#
this.radRating.Items.Clear();
RadRatingItem ratingItem = new RadRatingItem();
ratingItem.Content = "1";
this.radRating.Items.Add(ratingItem);
ratingItem = new RadRatingItem();
ratingItem.Content = "2";
this.radRating.Items.Add(ratingItem);
```

```VB.NET
	Me.radRating.Items.Clear() 
	Dim ratingItem As New RadRatingItem()
	ratingItem.Content = "1"
	Me.radRating.Items.Add(ratingItem)
	ratingItem As New RadRatingItem()
	ratingItem.Content = "2"
	Me.radRating.Items.Add(ratingItem)
```

> caption Result from example 3

![RadRating](https://www.telerik.com/products/wpf/documentation/assets/ec83ae8ca4b49d60ce475971d4e53e1c/rating_with__2_items.png)

> tip Consider declaring rating items in XAML instead of adding them by code whenever it's possible. This includes situations when you know what items you need at design time.

## Removing RadRatingItems

In order to remove a specific **RadRatingItem**, you should remove it from the **RadRating**'s **Items** collection.

```C#
private void RemoveRatingItem(RadRatingItem itemToRemove)
{
    this.radRating.Items.Remove(itemToRemove);
}
```

```VB.NET
	Private Sub RemoveRatingItem(ByVal itemToRemove As RadRatingItem)
	    Me.radRating.Items.Remove(itemToRemove)
	End Sub
```
