Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemContainerGenerator System.ArgumentException An item with the same key has already been added #7467

Closed
wieslawsoltes opened this issue Jan 29, 2022 · 3 comments · Fixed by #9677
Labels

Comments

@wieslawsoltes
Copy link
Collaborator

wieslawsoltes commented Jan 29, 2022

Describe the bug

System.ArgumentException: An item with the same key has already been added. Key: [1, Avalonia.Controls.Generators.ItemContainerInfo]
   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   at System.Collections.Generic.SortedSet`1.Add(T item)
   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   at Avalonia.Controls.Generators.ItemContainerGenerator.MoveContainer(Int32 oldIndex, Int32 newIndex, Object item) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Generators\ItemContainerGenerator.cs:line 217
   at Avalonia.Controls.Generators.ItemContainerGenerator`1.TryRecycle(Int32 oldIndex, Int32 newIndex, Object item) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Generators\ItemContainerGenerator`1.cs:line 91
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.RecycleContainersForMove(Int32 delta) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 432
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.set_OffsetValue(Double value) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 68
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.ScrollIntoViewCore(Int32 index) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 543
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.ScrollIntoView(Int32 index) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 297
   at Avalonia.Controls.Presenters.ItemsPresenter.ScrollIntoView(Int32 index) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemsPresenter.cs:line 133
   at Avalonia.Controls.Primitives.SelectingItemsControl.ScrollIntoView(Int32 index) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 362
   at Avalonia.Controls.Primitives.SelectingItemsControl.AutoScrollToSelectedItemIfNecessary() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 848
   at Avalonia.Controls.Primitives.SelectingItemsControl.OnSelectionModelPropertyChanged(Object sender, PropertyChangedEventArgs e) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 763
   at Avalonia.Controls.Selection.SelectionModel`1.RaisePropertyChanged(String propertyName) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 277
   at Avalonia.Controls.Selection.SelectionModel`1.CommitOperation(Operation operation, Boolean raisePropertyChanged) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 726
   at Avalonia.Controls.Selection.SelectionModel`1.EndBatchUpdate() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 214
   at Avalonia.Controls.Selection.SelectionModel`1.BatchUpdateOperation.Dispose() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 764
   at Avalonia.Controls.Selection.SelectionModel`1.SelectRange(Int32 start, Int32 end, Boolean forceSelectedIndex, Boolean forceAnchorIndex) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 565
   at Avalonia.Controls.Selection.SelectionModel`1.Select(Int32 index) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 235
   at Avalonia.Controls.Primitives.SelectingItemsControl.OnContainersMaterialized(ItemContainerEventArgs e) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 430
   at Avalonia.Controls.ItemsControl.<get_ItemContainerGenerator>b__12_0(Object _, ItemContainerEventArgs e) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\ItemsControl.cs:line 93
   at Avalonia.Controls.Generators.ItemContainerGenerator.Materialize(Int32 index, Object item) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Generators\ItemContainerGenerator.cs:line 59
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.CreateAndRemoveContainers() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 334
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.UpdateControls() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 161
   at Avalonia.Controls.VirtualizingStackPanel.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\VirtualizingStackPanel.cs:line 87
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.Presenters.ItemVirtualizerSimple.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemVirtualizerSimple.cs:line 154
   at Avalonia.Controls.Presenters.ItemsPresenter.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ItemsPresenter.cs:line 139
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.Presenters.ScrollContentPresenter.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ScrollContentPresenter.cs:line 253
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 1150
   at Avalonia.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 1005
   at Avalonia.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 968
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 427
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 625
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 46
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding, Thickness borderThickness) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 39
   at Avalonia.Controls.Border.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Border.cs:line 189
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 625
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\StackPanel.cs:line 207
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\StackPanel.cs:line 207
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\StackPanel.cs:line 207
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 230
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Grid.cs:line 230
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 46
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding, Thickness borderThickness) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 39
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Presenters\ContentPresenter.cs:line 366
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutHelper.cs:line 46
   at Avalonia.Controls.Decorator.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Decorator.cs:line 54
   at Avalonia.Controls.Primitives.VisualLayerManager.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Primitives\VisualLayerManager.cs:line 133
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 625
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 559
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 625
   at Avalonia.Controls.Window.MeasureOverride(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Window.cs:line 904
   at Avalonia.Controls.WindowBase.MeasureCore(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\WindowBase.cs:line 244
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\Layoutable.cs:line 364
   at Avalonia.Layout.LayoutManager.Measure(ILayoutable control) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutManager.cs:line 287
   at Avalonia.Layout.LayoutManager.ExecuteInitialLayoutPass() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Layout\LayoutManager.cs:line 174
   at Avalonia.Controls.Window.ShowCore(Window parent) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Window.cs:line 689
   at Avalonia.Controls.Window.Show() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\Window.cs:line 627
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.ShowMainWindow() in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 128
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 118
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in C:\DOWNLOADS\GitHub\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 209
   at Sandbox.Program.Main(String[] args) in C:\DOWNLOADS\GitHub\Avalonia\samples\Sandbox\Program.cs:line 7

To Reproduce

Sandbox

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
        x:Class="Sandbox.MainWindow">
    <ListBox BorderThickness="1">
        <ListBoxItem Content="Unselected"/>
        <ListBoxItem Content="Selected" IsSelected="True"/>
        <ListBoxItem Content="Disabled" IsEnabled="False"/>
    </ListBox>
</Window>

Expected behavior
No Exception

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 0.10.12 and master
@munzili
Copy link

munzili commented Mar 3, 2022

Also got similar Problem with ItemsControl

   bei System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   bei System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   bei Avalonia.Controls.Generators.ItemContainerGenerator.Materialize(Int32 index, Object item)
   bei Avalonia.Controls.Presenters.ItemContainerSync.AddContainers(ItemsPresenterBase owner, Int32 index, IEnumerable items)
   bei Avalonia.Controls.Presenters.ItemContainerSync.<ItemsChanged>g__Add|0_0(<>c__DisplayClass0_0& )
   bei Avalonia.Controls.Presenters.ItemContainerSync.ItemsChanged(ItemsPresenterBase owner, IEnumerable items, NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.Presenters.ItemVirtualizerNone.ItemsChanged(IEnumerable items, NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.Presenters.ItemsPresenter.ItemsChanged(NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.Presenters.ItemsPresenterBase.Avalonia.Controls.Presenters.IItemsPresenter.ItemsChanged(NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.ItemsControl.ItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.ItemsControl.Avalonia.Controls.Utils.ICollectionChangedListener.PostChanged(INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs e)
   bei Avalonia.Controls.Utils.CollectionChangedEventManager.Entry.<Avalonia.Utilities.IWeakEventSubscriber<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.OnEvent>g__Notify|6_0(INotifyCollectionChanged incc, NotifyCollectionChangedEventArgs args, List`1 listeners)
   bei Avalonia.Controls.Utils.CollectionChangedEventManager.Entry.<>c__DisplayClass6_0.<Avalonia.Utilities.IWeakEventSubscriber<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.OnEvent>b__1()
   bei Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority)
   bei Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   bei Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   bei Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   bei Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   bei Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   bei Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   bei XXX.Program.<Main>d__6.MoveNext() in D:\XXX\Program.cs: Zeile77

@Tenjim
Copy link

Tenjim commented Jun 9, 2022

Hi Guys,

I have this same issue when using ListBox with VirtualizationMode simple.
There is just one case are similar than @wieslawsoltes sample. I'm using "IsSelected" Property and a binding on it.

And when you remove IsSelected on his sample. There is no ArgumentException.

@Whiletru3
Copy link
Contributor

I have analyzed this bug.
The default behaviour of a ItemsControl has the AutoScrollToSelectedItem to true
This property, trigger the change ScrollIntoView on second element leading to the dictionary issue during MoveContainer.
Here is the commit description about the dictionnary : e686786

Use dictionary to track item containers.

Because even when virtualized we were still creating a list the size of
the Items collection to store the containers. Using Dictionary here
still isn't ideal - we'd ideally use some sort of sparse array but that
can be optimized later.

@grokys We are later now (+2200days) :)

As a workaround for now we can use AutoScrollToSelectedItem="False" in the ListBox :

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
        x:Class="Sandbox.MainWindow">
    <ListBox BorderThickness="1" AutoScrollToSelectedItem="False">
        <ListBoxItem Content="Unselected"/>
        <ListBoxItem Content="Selected" IsSelected="True"/>
        <ListBoxItem Content="Disabled" IsEnabled="False"/>
    </ListBox>
</Window>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants