SelectAndMove is a lightweight, modular Avalonia control for selecting and moving controls.
There are two examples provided in SelectAndMove, the first is a range of controls added directly via the xaml and the Items collection. This example has no code behind or data context, and exposes several controls that are bound directly to the various properties of SelectAndMove
See source code for this example
The second example is a more practical use, where the items are set via the ItemsSource property, which targets a list of item models on the view model, and uses a data template for those items. Selecting, adding, and deleting items all get redirected via the view model.
See source code for this example
SelectAndMove is an ItemsControl with custom pan, zoom, select, move, and marquee select functionality. The template for SelectAndMove depends on Panel#PART_TransformRoot, which is the visual that is transformed when the ViewZoom, ViewTranslateX, and ViewTranslateY properties are changed.
Selection and marquee selection are gestures that work within a custom selection system that be applied to any control. These scopes are an independent system from the SelectAndMove class; any controls in the logical tree can define themselves as SelectionScopes and any control can be selected.
Move is also a gesture, but it specifically sets the Canvas.Left and Canvas.Top properties of the selected elements.
BackgroundGridLines.cs is a self-contained control whose visual depends on its RenderTransform with respect to a specified visual ancestor (by default its TemplatedParent, or its logical parent if its TemplatedParent doesn't exist). In the context of SelectAndMove, it provides gridlines that automatically adapt to the current zoom level and that the move gesture can snap to.
A SelectingItemsControl may be more appropriate for a future version, but the base functionality of that class would need changing a lot to work within this system.
Thanks to the PanAndZoom for name and code inspiration. If all you need is the Pan and Zoom functionality, PanAndZoom may be easier to use.
SelectAndMove is licensed under the MIT license