void ISupportInitialize.EndInit() { if (_initializingData == null) { throw new InvalidOperationException(); } int selectedIndex = SelectedIndex; object selectedItem = SelectedItem; if (_initializingData.InitialIndex != selectedIndex) { SelectedIndex = _initializingData.InitialIndex; _initializingData = null; SelectedIndex = selectedIndex; } else if (!ReferenceEquals(_initializingData.InitialItem, selectedItem)) { SelectedItem = _initializingData.InitialItem; _initializingData = null; SelectedItem = selectedItem; } _initializingData = null; }
void ISupportInitialize.BeginInit() { _initializingData = new InitializingData { InitialItem = SelectedItem, InitialIndex = SelectedIndex }; }