Я хочу удалить все виды из моего региона в Composite. Я использую Silverlight 4.0.
И, к сожалению, этот код завершается с OutOfRangeException внутри Composite.
List<object> views = new List<object>(_regionManager.Regions["NavigationRegion"].Views);
foreach (object view in views)
{
_regionManager.Regions["NavigationRegion"].Remove(view);
}
Это мой callstack:
[Внешний код]
Microsoft.Practices.Composite.Presentation! Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs
e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs})
Строка 102 + 0x24 байта C #
Microsoft.Practices.Composite.Presentation! Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.RemoveAndNotify (System.Collections.IList
items = Count = 1) Строка 45 + 0x2b байтов C #
Microsoft.Practices.Composite.Presentation! Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.UnderlyingCollection_CollectionChanged (объект
отправитель = счетчик = 0,
System.Collections.Specialized.NotifyCollectionChangedEventArgs e =
{} System.Collections.Specialized.NotifyCollectionChangedEventArgs)
Строка 153 + 0xb байтов C # [Внешний код]
Microsoft.Practices.Composite.Presentation! Microsoft.Practices.Composite.Presentation.Regions.Region.Remove (объект
view = {Kite.MyApp.SlUI.NavigationRegion.NavigationRegionView}) Строка
230 + 0x1b байт C #
MyApp.SlUI! Kite.MyApp.SlUI.Components.ViewController.linksRegion_LanguageChanged (объект
sender = {Kite.MyApp.SlUI.Controls.LinksUserControl},
Kite.MyApp.SlUI.Common.EventArgs e =
{Kite.MyApp.SlUI.Common.EventArgs}) Строка 77 + 0x2d байт C #
MyApp.SlUI! Kite.MyApp.SlUI.Controls.LinksUserControl.OnLanguageChanged (строка
newLanguage = "en-GB") Строка 37 + 0x32 байта C #
MyApp.SlUI! Kite.MyApp.SlUI.Controls.LinksUserControl.ComboBox_SelectionChanged (объект
sender = {System.Windows.Controls.ComboBox},
System.Windows.Controls.SelectionChangedEventArgs e =
{System.Windows.Controls.SelectionChangedEventArgs}) Строка 31 + 0xb
байты C # [внешний код]
Что я не так сделал?
P.S. В моем регионе у меня 3 просмотра. Итак, композит вылетает при удалении третьего.
Надеюсь на вашу помощь :). Спасибо.
UPD: я загрузил символы отладки и обнаружил, что проблема заключается только в управлении аккордеоном в качестве региона.
Это полный стек вызовов:
mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource) + 0x41 bytes
mscorlib.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException() + 0x10 bytes
mscorlib.dll!System.Collections.Generic.List<object>.this[int].get(int index = 0) + 0x13 bytes
System.Windows.dll!System.Windows.Controls.ItemCollection.GetItemImpl(int index) + 0x15 bytes
System.Windows.dll!System.Windows.Controls.ItemCollection.GetItemImplSkipMethodPack(int index) + 0xb bytes
System.Windows.dll!System.Windows.PresentationFrameworkCollection<System.__Canon>.this[int].get(int index) + 0xb bytes
System.Windows.Controls.Layout.Toolkit!System.Windows.Controls.Accordion.UnselectItem(int index = 0, object item = null) + 0x1aa bytes
System.Windows.Controls.Layout.Toolkit!System.Windows.Controls.Accordion.ChangeSelectedIndex(int oldIndex = 0, int newIndex = -1) + 0x14c bytes
System.Windows.Controls.Layout.Toolkit!System.Windows.Controls.Accordion.OnSelectedIndexPropertyChanged(System.Windows.DependencyObject d = {System.Windows.Controls.Accordion}, System.Windows.DependencyPropertyChangedEventArgs e = {System.Windows.DependencyPropertyChangedEventArgs}) + 0x1d9 bytes
System.Windows.dll!System.Windows.DependencyObject.RaisePropertyChangeNotifications(System.Windows.DependencyProperty dp = {System.Windows.CustomDependencyProperty}, object oldValue, object newValue) + 0x51 bytes
System.Windows.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.DependencyProperty property, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, System.Windows.DependencyObject.ValueOperation operation) + 0xf5 bytes
System.Windows.dll!System.Windows.DependencyObject.SetValueInternal(System.Windows.DependencyProperty dp, object value, bool allowReadOnlySet) + 0x2ad bytes
System.Windows.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0xb bytes
System.Windows.Controls.Layout.Toolkit!System.Windows.Controls.Accordion.SelectedIndex.set(int value = -1) + 0x4d bytes
System.Windows.Controls.Layout.Toolkit!System.Windows.Controls.Accordion.OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) + 0x737 bytes
System.Windows.dll!System.Windows.Controls.ItemsControl.OnItemCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x52 bytes
System.Windows.dll!System.Windows.Controls.ItemCollection.NotifyCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x37 bytes
System.Windows.dll!System.Windows.Controls.ItemCollection.NotifyItemsCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x1f bytes
System.Windows.dll!System.Windows.Controls.ItemCollection.EnumerableCollectionView.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x4f bytes
System.Windows.dll!System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x3d bytes
Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) Line 102 + 0x24 bytes C#
Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.RemoveAndNotify(System.Collections.IList items = Count = 1) Line 45 + 0x2b bytes C#
Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.UnderlyingCollection_CollectionChanged(object sender = Count = 0, System.Collections.Specialized.NotifyCollectionChangedEventArgs e = {System.Collections.Specialized.NotifyCollectionChangedEventArgs}) Line 153 + 0xb bytes C#
System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<Microsoft.Practices.Composite.Presentation.Regions.ItemMetadata>.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x37 bytes
System.Windows.dll!System.Collections.ObjectModel.ObservableCollection<System.__Canon>.RemoveItem(int index) + 0xa1 bytes
mscorlib.dll!System.Collections.ObjectModel.Collection<Microsoft.Practices.Composite.Presentation.Regions.ItemMetadata>.Remove(Microsoft.Practices.Composite.Presentation.Regions.ItemMetadata item) + 0x75 bytes
Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.Region.Remove(object view = {Kite.MyApp.SlUI.NavigationRegion.NavigationRegionView}) Line 230 + 0x1b bytes C#