Skip to main content
Home Forums General Silverlight Installation and Setup ComboBox Binding
3 replies. Latest Post by rajeshkumar.a@gmail.com on January 5, 2009.
(0)
wish.nikhil
Member
14 points
6 Posts
12-30-2008 12:16 AM |
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
preishuber
Contributor
3570 points
655 Posts
12-30-2008 2:30 AM |
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}">
01-05-2009 12:22 AM |
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.
rajeshku...
168 points
51 Posts
01-05-2009 4:53 AM |
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.