Steve French
Steve French

Reputation: 991

Combobox in a Silverlight 3.0 dataform

With the new release of Silverlight 3 and the move of the DataForm to the SilverLight Toolkit - does anyone know how to programatically add items to a combobox in a DataForm? There doesn't seem to be any of accessing it via the code file/

Thanks ~Steve

Upvotes: 2

Views: 3211

Answers (2)

Dipen Lama
Dipen Lama

Reputation: 1

private void dataForm_ContentLoaded(object sender, DataFormContentLoadEventArgs e)
{    
  Dictionary<string, short> products= GetProducts();
  foreach (string key in products.Keys)
  {
     ComboBoxItem listBoxItem = new ComboBoxItem();
     ComboBox cmbProducts = (ComboBox)dataForm.FindNameInContent  
     ("cmbProducts"); 
     listBoxItem.Name = cmbProducts.Name + key;
     listBoxItem.Content = key;
     cmbProducts.Items.Add(listBoxItem);
  }
}


On the XAML declare teh event for ur dataForm.

Upvotes: 0

VojTas
VojTas

Reputation: 56

Yes, you can manage it by

dataForm.ContentLoaded += (sender, args) =>
{
    TextBox myTextBox = (TextBox)dataForm.FindNameInContent("myTextBox");
    // do something with the TextBox...
};

Look in here for details: http://silverlight.net/forums/t/108278.aspx

Upvotes: 4

Related Questions