我有一个问题,在关闭UserControl时,我的组合框丢失了它的SelectedIndex值。 ViewModel仍然有它,但视图不断地将其重置为-1。我知道绑定ItemSource和SelectedIndex的顺序有问题,但我没有直接绑定到ItemSource。基本上,我试图找出下面的绑定正确的语法。组合框丢失SelectedIndex
</ComboBox.ItemTemplate>
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem IsEnabled="False">Select a database connection...</ComboBoxItem>
<CollectionContainer Collection="{Binding Source={StaticResource ConnectionsBridge}}" />
<ComboBoxItem><New...></ComboBoxItem>
</CompositeCollection>
</ComboBox.ItemsSource>
**<ComboBox.SelectedIndex>
<Binding Path="SelectedConnectionIndex"/>
</ComboBox.SelectedIndex>**
</ComboBox>
原来,结合现在是正确的感谢Shawn的回应,但该指数仍是重置模式属性。 – nathantruant