Callback-based zoom/offset workaround for Avalonia PanAndZoom#4
Draft
Callback-based zoom/offset workaround for Avalonia PanAndZoom#4
Conversation
…backs - Add readOnlyZoomAndOffsets parameter to ViewTabViewModel constructor (default false) - Add ApplyTransformCallback and PanStepCallback callback properties - Modify Fill, Fit, Zoom100, DefferedFill to use callbacks in read-only mode - Modify StartScrollingAsync to use step-per-second translation via callback - Pass readOnlyZoomAndOffsets=true in Avalonia DI registration - Remove PanelAttributesAP bindings from Avalonia ZoomBorder XAML - Register ZoomBorder matrix callbacks in MainWindow.Methods.axaml.cs - WPF version remains completely unaffected Agent-Logs-Url: https://github.com/JohnnyJF10/TgaBuilder/sessions/dd11e2f8-35b2-4466-9eed-5693e68e6e9b Co-authored-by: JohnnyJF10 <83164789+JohnnyJF10@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
JohnnyJF10
April 12, 2026 18:06
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avalonia's PanAndZoom
ZoomBorderonly exposes zoom and offset as read-only (unlike WPF's two-way bindable ZoomPanel), and the absolute offset values are unreliable. This makes the existingViewTabViewModelbinding-driven approach non-functional for Avalonia.Approach
Adds a
readOnlyZoomAndOffsetsconstructor parameter toViewTabViewModel(defaultfalse, WPF untouched). Whentrue, programmatic view changes (Fill, Fit, Zoom100, scrolling) use registered callbacks that directly manipulateZoomBorder.SetMatrix()instead of pushing values through bindings.Changes
ViewTabViewModel— newbool readOnlyZoomAndOffsetsctor param;ApplyTransformCallback(zoom, tx, ty)for absolute transforms;PanStepCallback(dx, dy)for incremental panning. All mutating methods (Fill,Fit,Zoom100,DefferedFill,StartScrollingAsync) branch on the flag.MainWindow.Methods.axaml.cs—RegisterZoomBorderCallbacks()wires callbacks toZoomBorder.SetMatrix()viaDispatcher.UIThread.PostMainWindow.axaml.cs— registers callbacks onOpenedfor both source/target panelsMainWindow.axaml— removedPanelAttributesAP.*andOffsetX/OffsetYbindings from bothZoomBorders (replaced by callbacks); retainedZoomX/ZoomYOneWayToSource so the VM still reads gesture zoomApp.DI.axaml.cs— passesreadOnlyZoomAndOffsets: truefor bothViewTabViewModelregistrationsWPF project: zero files changed.
Scrolling in read-only mode uses a 1-second step interval per the issue requirements rather than the WPF 3ms continuous loop.