Mvvm 绑定到combobox时,如何将默认索引设置为0?

Mvvm 绑定到combobox时,如何将默认索引设置为0?,mvvm,silverlight-4.0,Mvvm,Silverlight 4.0,我在应用程序中使用MVVM,并将combobox绑定到我的集合。但是,当我运行它时,组合框没有任何选定的索引,它显示一个丑陋的emtpy框。我如何克服这个问题 这是我的代码:- <ComboBox x:Name="cmbPasswordQuestion" ItemsSource="{Binding PasswordQuestionList}" DisplayMemberPath="SiteTermsXItemsName" SelectedValuePath="SiteTermsXI

我在应用程序中使用MVVM,并将combobox绑定到我的集合。但是,当我运行它时,组合框没有任何选定的索引,它显示一个丑陋的emtpy框。我如何克服这个问题

这是我的代码:-

  <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:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding PasswordQuestionCommand}" CommandParameter="{Binding SelectedItem, ElementName=cmbPasswordQuestion}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ComboBox>

我无法直接在xaml中设置
SelectedIndex=0
,因为我正在绑定集合运行时


提前感谢:)

您只需在初始化
PasswordQuestionList
属性后立即将
SignUpUser.PasswordQuestionId
设置为组合框中第一项的id即可。剩下的就用装订了。

我真傻!!谢谢,我怎么会想不起来呢。。!谢谢你