Selected Value in Combobox
-
Dear All, Here is my combobox in Silverlight
<ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber">
and i usedrpUserList.ItemsSource = e.Result;
To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value. -
Dear All, Here is my combobox in Silverlight
<ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber">
and i usedrpUserList.ItemsSource = e.Result;
To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value. -
Dear All, Here is my combobox in Silverlight
<ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber">
and i usedrpUserList.ItemsSource = e.Result;
To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.You can directly bind from XAML like this,
SelectedValue="{Binding UserID}"
Arun Jacob My Technical Blog : Code.NET
-
Dear All, Here is my combobox in Silverlight
<ComboBox x:Name="drpUserList" Width="200" Height="30" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left" DisplayMemberPath="FullName" SelectedValuePath="UserNumber">
and i usedrpUserList.ItemsSource = e.Result;
To fill my combobox, it works fine and will file the combobox with values but i want the selectedvalue which is my userid for selected user from dropdown. How could i get the value.Do the following:
var selectedUser = (from user in usersList
where user.UserId.Equals(selectedUserId)
select user).FirstOrDefault();drpUserList.SelectedItem = selectedUser;
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial