Take the 2-minute tour ×

I am using MVVM in my application and binding combobox to my collection. However when i run it the combobox doesn't have any selected index and it shows a ugly emtpy box. How do i get past this issue?

This is my code :-

  <ComboBox x:Name="cmbPasswordQuestion"  ItemsSource="{Binding PasswordQuestionList}"  DisplayMemberPath="SiteTermsXItemsName" SelectedValuePath="SiteTermsXItemId" SelectedValue="{Binding SignUpUser.PasswordQuestionId}" Margin="97,210,247,0" VerticalAlignment="Top" Height="24">
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding PasswordQuestionCommand}" CommandParameter="{Binding SelectedItem, ElementName=cmbPasswordQuestion}"/>

I am not able to set the SelectedIndex = 0 directly in xaml as i am binding the collection run time.

Thanks in advance :)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

All you need is to set SignUpUser.PasswordQuestionId to the id of the first item in the combobox right after you initialized the PasswordQuestionList property. And the binding will do the rest.

share|improve this answer
Silly me!! Thanks how could i not think of it..! Thanks anyways –  TCM Jan 19 '11 at 16:30
add comment

Your Answer


