Silverlight小技巧:在XAML设置ComboBox.ItemsSource及SelectedIndex时的注意点

刚才碰到个问题,运行SL程序后ComboBox总是显示为空白,即使设置了SelectedIndex也是一样。

弄了很久才想起来,ComboBox设置ItemsSource之后会把SelectedIndex重置为-1,所以SelectedIndex必须放在ItemsSource后面。

Leave a Reply

Your email address will not be published. Required fields are marked *