---
title: "Complex Data Binding in Silverlight"  
description: "In this demonstration we learn how to implement complex data binding in silver light. Here we show that how to bind data with list box control. We kno"  
author: "Anonymous User"  
published: 2011-03-09  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/485/complex-data-binding-in-silverlight  
category: "silverlight"  
tags: ["silverlight"]  
reading_time: 2 minutes  

---

# Complex Data Binding in Silverlight

In this demonstration we learn how to implement complex data binding in silver light. Here we show that how to bind data with list box control. We know that complex data binding means to bind data with such type of controls which have a capacity to show more than one value at a time. Best example for complex data binding is ListBox control, ComboBox control and DataGrid control etc. Here firstly we see that how to bind data with ListBox control.\

##### Write following XAML control to create a User Interface for this demonstration

```
<Grid x:Name="LayoutRoot" Background="White">        <ListBox x:Name="lstBox1" Width="100" VerticalAlignment="Top" Height="50" ItemsSource="{Binding}">            <ListBox.ItemTemplate>                <DataTemplate>                    <TextBlock Text="{Binding Name}"></TextBlock>                </DataTemplate>            </ListBox.ItemTemplate>        </ListBox></Grid>
```

##### Create a class name Employee

```
public class Employee{        public string Name { get; set; }        public string Age { get; set; }        public string City { get; set; }}
```

##### Create a method named GetEmployeeData() in MainPage class

```
public List<Employee> GetEmployeeData(){            List<Employee> emp = new List<Employee>();            emp.Add(new  Employee() { Name = "Awadhendra" });            emp.Add(new  Employee() { Name = "Abhishek" });            emp.Add(new  Employee() { Name = "Amit" });            emp.Add(new  Employee() { Name = "Haider" });            emp.Add(new  Employee() { Name = "Sachindra" });            emp.Add(new  Employee() { Name = "Uttam" });            return emp;}
```

##### At the load event of user control write down the following code

```
private void UserControl_Loaded(object sender,  RoutedEventArgs e){            lstBox1.DataContext = GetEmployeeData(); }
```

##### Save your application and then execute it to see the demonstration

![Complex Data Binding in Silverlight](https://www.mindstick.com/mindstickarticle/d9362d1c-8c5d-42ed-8677-4ecf08eed57b/images/cff46895-5bfb-45a5-9047-2f7470374d22.png)

\

---

Original Source: https://www.mindstick.com/articles/485/complex-data-binding-in-silverlight

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
