Skip to main content

Microsoft Silverlight

ComboBox BindingRSS Feed

(0)

wish.nikhil
wish.nikhil

Member

Member

14 points

6 Posts

ComboBox Binding

Hi all,

Just like WPF where we have Selected Value for ComboBox can't we have the same here in silverlight where only selected item is present as I am creating a custom control basically to interact with the DataBase and I do not know the name of the class to which the comboBox will bind.

 Thanks,

nikhil
 

Thanks,
nikhil

preishuber
preishuber

Contributor

Contributor

3570 points

655 Posts

Re: ComboBox Binding

i am not shure what you are looking for in detail. Bind like that

<ComboBox BorderThickness="0" ItemsSource="{Binding Path=Field1}" SelectedIndex="{Binding Path=Field1}">

-Hannes

http://www.preishuber.net http://weblogs.asp.net/hpreishuber

wish.nikhil
wish.nikhil

Member

Member

14 points

6 Posts

Re: ComboBox Binding

 All I am saying is that, can I have an extra property in comboBox which works just like Selected Value in WPF. As using selected Item is a tough  task while developing  a business application.

And since I want to create a custom control  for ComboBox specially for Databinding in which I am creating some dependency properties like Table Name Binding Column Name so that I can bind the comboBox accordingly.

For Example :- If a comboBox is inside a Grid which is its Parent and the ComboBox has an ItemsSource . Now the Grid has a DataContext, and suppose there is one ID property in that DataContext. Now according to that ID I want to display the Data in the ComboBox.   

The problem is that , since it is a custom control so I do not know the ItemsSource and DataContext type and thus I can't use Selected Item Property. Had the selected value and selected Value Path been there in Silverlight just like WPF the work would have been easier.  

Thanks,
nikhil

rajeshkumar.a@gmail.com
rajeshku...

Member

Member

168 points

51 Posts

Re: ComboBox Binding

Hi,

It seems that your question is not clear. If you are looking for Display text and its id for each item in combo box, you can following :

DisplayMemberPath="" // UserName

Tag="" // UserId

You can use any collection <IEnumerable> like List, DataTable etc to bind values to combo box.

(Please click on "Mark As Answer", if this has answered your query. Thanks)

Regards,
Rajesh
(http://rajeshkumara.wordpress.com)
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities