Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove all views in region in CompositeWPF/Silverlight
    primarykey
    data
    text
    <p>I want remove all views from my region in Composite. I'm using Silverlight 4.0.</p> <p>And unfortunately, this code crashes with OutOfRangeException inside Composite.</p> <pre><code> List&lt;object&gt; views = new List&lt;object&gt;(_regionManager.Regions["NavigationRegion"].Views); foreach (object view in views) { _regionManager.Regions["NavigationRegion"].Remove(view); } </code></pre> <p>This is my callstack:</p> <blockquote> <p>[External Code]<br> 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#<br> Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.ViewsCollection.RemoveAndNotify(System.Collections.IList items = Count = 1) Line 45 + 0x2b bytes C#<br> 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# [External Code]<br> Microsoft.Practices.Composite.Presentation!Microsoft.Practices.Composite.Presentation.Regions.Region.Remove(object view = {Kite.MyApp.SlUI.NavigationRegion.NavigationRegionView}) Line 230 + 0x1b bytes C#<br> MyApp.SlUI!Kite.MyApp.SlUI.Components.ViewController.linksRegion_LanguageChanged(object sender = {Kite.MyApp.SlUI.Controls.LinksUserControl}, Kite.MyApp.SlUI.Common.EventArgs e = {Kite.MyApp.SlUI.Common.EventArgs}) Line 77 + 0x2d bytes C#<br> MyApp.SlUI!Kite.MyApp.SlUI.Controls.LinksUserControl.OnLanguageChanged(string newLanguage = "en-GB") Line 37 + 0x32 bytes C#<br> MyApp.SlUI!Kite.MyApp.SlUI.Controls.LinksUserControl.ComboBox_SelectionChanged(object sender = {System.Windows.Controls.ComboBox}, System.Windows.Controls.SelectionChangedEventArgs e = {System.Windows.Controls.SelectionChangedEventArgs}) Line 31 + 0xb bytes C# [External Code]</p> </blockquote> <p>What did I wrong?</p> <p>P.S. In my region I have 3 views. So, composite crashes on removing the third.</p> <p>Hoping for you help :). Thank you.</p> <p>UPD: I downloaded debug symbols and found that problem is only in Accordion control as region. This is full call stack:</p> <pre><code>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&lt;object&gt;.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&lt;System.__Canon&gt;.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&lt;Microsoft.Practices.Composite.Presentation.Regions.ItemMetadata&gt;.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + 0x37 bytes System.Windows.dll!System.Collections.ObjectModel.ObservableCollection&lt;System.__Canon&gt;.RemoveItem(int index) + 0xa1 bytes mscorlib.dll!System.Collections.ObjectModel.Collection&lt;Microsoft.Practices.Composite.Presentation.Regions.ItemMetadata&gt;.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# </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload