Open ArsenAbazian opened 1 year ago
better to work with the MVVM approach and use ItemTemplates. Your items can then be added or removed as needed.
@ArsenAbazian Trying your sample I still think this is not a good idea to do in Avalonia. This approach has some drawbacks:
Attached please find an alternative, using the CommunityToolkit.Mvvm
package
AvaloniaApplication1.zip
Please visit https://github.com/AvaloniaUI/Avalonia.Samples for more samples and tutorials.
This is a legit bug. Cross-window control reparenting should be supported.
Describe the bug There are two similar windows with ItemsControl in them. In first window ItemsControl contains one item, for example: Button. In one moment the button is removed from the current ItemsControl.Items collection and added to the ItemsControl.Items in ItemsControl, located in other window. After that if you try to resize the first window, an "Attempt to call InvalidateArrange on wrong LayoutManager" exception will be thrown.
To Reproduce
Expected behavior No exception is thrown, Button1 successfully appear in Window2 and disappear from Window1
Desktop (please complete the following information): OS: Windows 11 Avalonia version: 11.0.4
Additional context I added the sample project, demonstating the issue. Please run the sample project and press the "Move Item To Main Window Container" button in FloatingWindow. Notice that button is not moved to MainWidow and stays in FloatingWindow. Then try to resize FloatingWindow. As a workaround try to call the UpdateLayout method after removing the button from first ItemsControl. AvaloniaApplication1.zip
Thank you, Arsen.