Skip to main content

Microsoft Silverlight

Answered Question Bind drop down in side dataform controlRSS Feed

(0)

saurabh951
saurabh951

Member

Member

17 points

36 Posts

Bind drop down in side dataform control

in my silverlight 3.0 application 

i have a combo box inside the dataform control.

<df:DataField Label="dbField">

<ComboBox">

</ComboBox>

</df:DataField>

now i want to bind that combobox from database before binding the dataform

how is it possible????/

thanx 

 

Ardman
Ardman

Contributor

Contributor

3202 points

890 Posts

Re: Bind drop down in side dataform control

 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.

saurabh951
saurabh951

Member

Member

17 points

36 Posts

Re: Bind drop down in side dataform control

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.

thanx

Ardman
Ardman

Contributor

Contributor

3202 points

890 Posts

Re: Re: Bind drop down in side dataform control

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 Tang - MSFT
Min-Hong...

Contributor

Contributor

2894 points

354 Posts

Answered Question

Re: Bind drop down in side dataform control

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

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities