Bind values to DataTemplate in silverlight.

This Blog describes how to bind values to DataTemplate in silverlight. 

1. Here we have Combobox Datatemplete in Xaml Page which design as follow. 

        <DataTemplate x:Key="cmbboxDataTemplete">
            <ComboBox Height="20" HorizontalAlignment="Left" Loaded="cmbName_Loaded" Width="150"  Name="cmbName"  MaxWidth="200" >

2. On Loaded Event we can bind the values to combobox shown as follow. 

Here sender is our combobox which name is cmbName. 

private void cmbName_Loaded(object sender, RoutedEventArgs e)

          ((ComboBox)sender).ItemsSource = modelperlist;
          ((ComboBox)sender).DisplayMemberPath = "Name";
          ((ComboBox)sender).SelectedValuePath = "iID";
          ((ComboBox)sender).IsDropDownOpen = true;

3. First find the datatemplete and get the selected value from combobox as follow. 

var combobox = coll.GetCellContent(item).FindName("cmbName") as ComboBox;
NameClass cmblist = combobox.SelectionBoxItem as NameClass ;
MessageBox.Show(cmblist.Name);//Here we get combobox selected item.