Skip to main content
Home Forums Silverlight Design Designing with Silverlight Bind drop down in side dataform control
4 replies. Latest Post by Min-Hong Tang - MSFT on November 11, 2009.
(0)
saurabh951
Member
17 points
36 Posts
11-06-2009 1:04 PM |
in my silverlight 3.0 application
i have a combo box inside the dataform control.
<
now i want to bind that combobox from database before binding the dataform
how is it possible????/
thanx
Ardman
Contributor
3202 points
890 Posts
11-07-2009 5:51 AM |
You'll need to load the data for your ComboBox in your constructor and set a LoadedEvent method for this. Once the data has loaded, you'll then need to load the data for your DataForm in the LoadedEvent of the ComboBox data.
11-09-2009 5:53 AM |
thanx for rply
but i cant access the combobox by name in code behind as combobox is inside dataform control.
also i want to set selected item of combobox as per the itemsource of dataform.
11-09-2009 6:09 AM |
In your code, if you do something like the following you'll get the control:
ComboBox cb = this.FindName("comboBox");
if (cb != null){
// ... do your stuff here}
Min-Hong...
2894 points
354 Posts
11-11-2009 3:43 AM |
Hi,
Em, What do you mean by set the ComboBox's itemsSource before dataform. Here is the situation.
If you do not set itemsSource for a dataform it's currentItem will be null. This means it will not load it's ReadOnlyTemplate. So the combobox of couse will not be load.
In this case you can not get the combo(it's not exist yet).
You can manually set a current item of a dataform. Then you will be able to get the combo's reference.
You can get if after it's loaded using code : dataform.FindNameInContent("combo").
Notice the combo is loaded after the mainPage, also after the dataform. So if you try to find it in those period it will return you null.
Best Regards