Page view counter
ComboBox Binding Subscribe to this thread
Last post 01-05-2009 4:53 AM by rajeshkumar.a@gmail.com. 3 replies.
Sort Posts:
12-30-2008 12:16 AM
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

wish.nikhil

Loading...
Joined on 12-29-2008
Bangalore
Posts 6
12-30-2008 2:30 AM
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

preishuber

Loading...
Joined on 09-20-2002
Austria/Germany
Posts 434
01-05-2009 12:22 AM
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

wish.nikhil

Loading...
Joined on 12-29-2008
Bangalore
Posts 6
01-05-2009 4:53 AM
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

rajeshkumar.a@gmail.com

Loading...
Joined on 12-09-2008
India
Posts 45
Microsoft Communities