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

ListBox inside Carousel will inherit PanelTemplate and crash when click to ListBoxItem #10374

Closed
SKProCH opened this issue Feb 16, 2023 · 2 comments · Fixed by #10470
Closed
Assignees
Labels

Comments

@SKProCH
Copy link
Contributor

SKProCH commented Feb 16, 2023

Describe the bug
When the ListBox are inside Carousel, ListBox's ItemsPanel will inherit PanelTemplate from Carousel (VirtualizingCarouselPanel), and when we click to a ListBox item (while AutoScrollToSelectedItem is true) we got the following exception:

System.NotImplementedException: The method or operation is not implemented.
   at Avalonia.Controls.VirtualizingCarouselPanel.Avalonia.Controls.Primitives.ILogicalScrollable.BringIntoView

To Reproduce
Steps to reproduce the behavior:

  1. Go to Avalonia repo

  2. Open the MainWindow.xaml in VirtualizationDemo

  3. Wrap ListBox with Carousel
    image

  4. Launch and try to click on any ListBox item

Expected behavior
ListBox shouldn't crash when we click to ListBoxItem

Desktop (please complete the following information):

  • OS: Any
  • Version: 11.0.0-preview5

Additional context
Stacktrace:

System.NotImplementedException: The method or operation is not implemented.
   at Avalonia.Controls.VirtualizingCarouselPanel.Avalonia.Controls.Primitives.ILogicalScrollable.BringIntoView(Control target, Rect targetRect) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\VirtualizingCarouselPanel.cs:line 85
   at Avalonia.Controls.Presenters.ItemsPresenter.Avalonia.Controls.Primitives.ILogicalScrollable.BringIntoView(Control target, Rect targetRect) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Presenters\ItemsPresenter.cs:line 210
   at Avalonia.Controls.Presenters.ScrollContentPresenter.BringDescendantIntoView(Visual target, Rect targetRect) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Presenters\ScrollContentPresenter.cs:line 258
   at Avalonia.Controls.Presenters.ScrollContentPresenter.BringIntoViewRequested(Object sender, RequestBringIntoViewEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Presenters\ScrollContentPresenter.cs:line 670
   at Avalonia.Interactivity.Interactive.<AddHandler>g__InvokeAdapter|4_0[TEventArgs](Delegate baseHandler, Object sender, RoutedEventArgs args) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\Interactive.cs:line 67
   at Avalonia.Interactivity.Interactive.<>c__4`1.<AddHandler>b__4_1(Delegate baseHandler, Object sender, RoutedEventArgs args) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\Interactive.cs:line 70
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\EventRoute.cs:line 164
   at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\EventRoute.cs:line 101
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\Interactive.cs:line 125
   at Avalonia.Controls.ControlExtensions.BringIntoView(Control control, Rect rect) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\ControlExtensions.cs:line 40
   at Avalonia.Controls.ControlExtensions.BringIntoView(Control control) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\ControlExtensions.cs:line 19
   at Avalonia.Controls.VirtualizingStackPanel.ScrollIntoView(Int32 index) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\VirtualizingStackPanel.cs:line 322
   at Avalonia.Controls.Presenters.ItemsPresenter.ScrollIntoView(Int32 index) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Presenters\ItemsPresenter.cs:line 218
   at Avalonia.Controls.Primitives.SelectingItemsControl.ScrollIntoView(Int32 index) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 413
   at Avalonia.Controls.Primitives.SelectingItemsControl.AutoScrollToSelectedItemIfNecessary() in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 1094
   at Avalonia.Controls.Primitives.SelectingItemsControl.OnSelectionModelPropertyChanged(Object sender, PropertyChangedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 897
   at Avalonia.Controls.Selection.SelectionModel`1.RaisePropertyChanged(String propertyName) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 274
   at Avalonia.Controls.Selection.SelectionModel`1.CommitOperation(Operation operation, Boolean raisePropertyChanged) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 722
   at Avalonia.Controls.Selection.SelectionModel`1.EndBatchUpdate() in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Selection\SelectionModel.cs:line 211
   at Avalonia.Controls.Selection.SelectionModelExtensions.BatchUpdateOperation.Dispose() in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Selection\ISelectionModel.cs:line 58
   at Avalonia.Controls.Primitives.SelectingItemsControl.UpdateSelection(Int32 index, Boolean select, Boolean rangeModifier, Boolean toggleModifier, Boolean rightButton, Boolean fromFocus) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 818
   at Avalonia.Controls.Primitives.SelectingItemsControl.UpdateSelection(Control container, Boolean select, Boolean rangeModifier, Boolean toggleModifier, Boolean rightButton, Boolean fromFocus) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 849
   at Avalonia.Controls.Primitives.SelectingItemsControl.UpdateSelectionFromEventSource(Object eventSource, Boolean select, Boolean rangeModifier, Boolean toggleModifier, Boolean rightButton, Boolean fromFocus) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\Primitives\SelectingItemsControl.cs:line 879
   at Avalonia.Controls.ListBox.OnPointerPressed(PointerPressedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\ListBox.cs:line 136
   at Avalonia.Input.InputElement.<>c.<.cctor>b__32_8(InputElement x, PointerPressedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Input\InputElement.cs:line 224
   at Avalonia.Interactivity.RoutedEvent`1.<>c__DisplayClass1_0`1.<AddClassHandler>g__Adapter|0(Object sender, RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\RoutedEvent.cs:line 125
   at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass23_0.<AddClassHandler>b__0(ValueTuple`2 args) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\RoutedEvent.cs:line 92
   at Avalonia.Reactive.AnonymousObserver`1.OnNext(T value) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Reactive\AnonymousObserver.cs:line 65
   at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Reactive\LightweightObservableBase.cs:line 145
   at Avalonia.Reactive.LightweightSubject`1.OnNext(T value) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Reactive\LightweightSubject.cs:line 24
   at Avalonia.Interactivity.RoutedEvent.InvokeRaised(Object sender, RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\RoutedEvent.cs:line 99
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\EventRoute.cs:line 146
   at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\EventRoute.cs:line 101
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Interactivity\Interactive.cs:line 125
   at Avalonia.Input.MouseDevice.MouseDown(IMouseDevice device, UInt64 timestamp, IInputElement root, Point p, PointerPointProperties properties, KeyModifiers inputModifiers, IInputElement hitTest) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Input\MouseDevice.cs:line 143
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Input\MouseDevice.cs:line 74
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Input\MouseDevice.cs:line 31
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Input\InputManager.cs:line 35
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\TopLevel.cs:line 633
   at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Windows\Avalonia.Win32\WindowImpl.AppWndProc.cs:line 753
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Windows\Avalonia.Win32\WindowImpl.WndProc.cs:line 23
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Windows\Avalonia.Win32\Win32Platform.cs:line 215
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Base\Threading\Dispatcher.cs:line 61
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 122
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) in C:\Users\SKProCH\RiderProjects\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 214
   at VirtualizationDemo.Program.Main(String[] args) in C:\Users\SKProCH\RiderProjects\Avalonia\samples\VirtualizationDemo\Program.cs:line 13
@SKProCH SKProCH added the bug label Feb 16, 2023
@SKProCH
Copy link
Contributor Author

SKProCH commented Feb 16, 2023

Actually crash reproduces on all ItemsPresenter based controls. For example, multiline TextBox are affected too:

System.NotImplementedException: The method or operation is not implemented.
   at Avalonia.Controls.VirtualizingCarouselPanel.Avalonia.Controls.Primitives.ILogicalScrollable.BringIntoView(Control target, Rect targetRect) in /_/src/Avalonia.Controls/VirtualizingCarouselPanel.cs:line 85
   at Avalonia.Controls.Presenters.ItemsPresenter.Avalonia.Controls.Primitives.ILogicalScrollable.BringIntoView(Control target, Rect targetRect) in /_/src/Avalonia.Controls/Presenters/ItemsPresenter.cs:line 210
   at Avalonia.Controls.Presenters.ScrollContentPresenter.BringDescendantIntoView(Visual target, Rect targetRect) in /_/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs:line 258
   at Avalonia.Controls.Presenters.ScrollContentPresenter.BringIntoViewRequested(Object sender, RequestBringIntoViewEventArgs e) in /_/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs:line 670
   at Avalonia.Interactivity.Interactive.<AddHandler>g__InvokeAdapter|4_0[TEventArgs](Delegate baseHandler, Object sender, RoutedEventArgs args) in /_/src/Avalonia.Base/Interactivity/Interactive.cs:line 64
   at Avalonia.Interactivity.Interactive.<>c__4`1.<AddHandler>b__4_1(Delegate baseHandler, Object sender, RoutedEventArgs args) in /_/src/Avalonia.Base/Interactivity/Interactive.cs:line 70
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/EventRoute.cs:line 164
   at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/EventRoute.cs:line 101
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/Interactive.cs:line 125
   at Avalonia.Controls.ControlExtensions.BringIntoView(Control control, Rect rect) in /_/src/Avalonia.Controls/ControlExtensions.cs:line 40
   at Avalonia.Controls.Presenters.TextPresenter.CaretChanged() in /_/src/Avalonia.Controls/Presenters/TextPresenter.cs:line 497
   at Avalonia.Controls.Presenters.TextPresenter.MoveCaretToPoint(Point point) in /_/src/Avalonia.Controls/Presenters/TextPresenter.cs:line 683
   at Avalonia.Controls.TextBox.OnPointerPressed(PointerPressedEventArgs e) in /_/src/Avalonia.Controls/TextBox.cs:line 1422
   at Avalonia.Input.InputElement.<>c.<.cctor>b__32_8(InputElement x, PointerPressedEventArgs e) in /_/src/Avalonia.Base/Input/InputElement.cs:line 224
   at Avalonia.Interactivity.RoutedEvent`1.<>c__DisplayClass1_0`1.<AddClassHandler>g__Adapter|0(Object sender, RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/RoutedEvent.cs:line 125
   at Avalonia.Interactivity.RoutedEvent.<>c__DisplayClass23_0.<AddClassHandler>b__0(ValueTuple`2 args) in /_/src/Avalonia.Base/Interactivity/RoutedEvent.cs:line 92
   at Avalonia.Reactive.AnonymousObserver`1.OnNext(T value) in /_/src/Avalonia.Base/Reactive/AnonymousObserver.cs:line 65
   at Avalonia.Reactive.LightweightObservableBase`1.PublishNext(T value) in /_/src/Avalonia.Base/Reactive/LightweightObservableBase.cs:line 143
   at Avalonia.Reactive.LightweightSubject`1.OnNext(T value) in /_/src/Avalonia.Base/Reactive/LightweightSubject.cs:line 24
   at Avalonia.Interactivity.RoutedEvent.InvokeRaised(Object sender, RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/RoutedEvent.cs:line 99
   at Avalonia.Interactivity.EventRoute.RaiseEventImpl(RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/EventRoute.cs:line 146
   at Avalonia.Interactivity.EventRoute.RaiseEvent(Interactive source, RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/EventRoute.cs:line 101
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) in /_/src/Avalonia.Base/Interactivity/Interactive.cs:line 125
   at Avalonia.Input.MouseDevice.MouseDown(IMouseDevice device, UInt64 timestamp, IInputElement root, Point p, PointerPointProperties properties, KeyModifiers inputModifiers, IInputElement hitTest) in /_/src/Avalonia.Base/Input/MouseDevice.cs:line 143
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e) in /_/src/Avalonia.Base/Input/MouseDevice.cs:line 74
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawInputEventArgs e) in /_/src/Avalonia.Base/Input/MouseDevice.cs:line 31
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) in /_/src/Avalonia.Base/Input/InputManager.cs:line 35
   at Avalonia.Controls.TopLevel.HandleInput(RawInputEventArgs e) in /_/src/Avalonia.Controls/TopLevel.cs:line 632
   at Avalonia.Win32.WindowImpl.AppWndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs:line 750
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs:line 30
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 204
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 61
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 212
   at Material.Demo.Program.Main(String[] args) in C:\Users\SKProCH\RiderProjects\material.avalonia\Material.Demo\Program.cs:line 14

@Nanonid
Copy link

Nanonid commented Feb 22, 2023

I'll test your branch if you wish.

grokys added a commit that referenced this issue Feb 24, 2023
`VirtualizingCarouselPanel` can't bring items into view (it can't scroll) or get a control in a direction (it only hosts one control) but we shouldn't throw `NotImplementedException` as these methods can still be called. Just make them a no-op.

Fixes #10374
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.

3 participants