Fix container overlay items displaying outside bounds - #30
Merged
Conversation
Fixes #12. Avalonia sets ClipToBounds=true by default on most layout containers, unlike WPF which leaves it false. Pack makers rely on negative margins and overflow rendering (e.g. overlay items positioned outside their container bounds). This causes items with negative margins or out-of-bounds placement to be silently clipped instead of drawn. Fix: add global Application-level styles setting ClipToBounds=False on all common layout container types (Grid, StackPanel, Panel, WrapPanel, DockPanel, ItemsControl, ContentControl, ContentPresenter, Border, Decorator, Viewbox, ScrollContentPresenter, ItemsPresenter). LayoutTransformControl overrides ClipToBounds in its static constructor so a UserControl-scoped style is added to LayoutControl to win via style proximity. Also explicitly set ClipToBounds=False on ItemGridControl's inner elements, and add HorizontalAlignment/VerticalAlignment=Stretch to the Button in TrackableItemControl so it fills its grid cell correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
emosaru
force-pushed
the
fix/issue-12-clip-to-bounds
branch
from
April 11, 2026 22:48
5d5567a to
229cd4f
Compare
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.
Summary
ClipToBounds=trueby default on most layout containers, unlike WPF which leaves it false. Pack makers rely on negative margins and overflow rendering (overlay items positioned outside their container bounds) which are silently clipped in Avalonia.Application.StylessettingClipToBounds=Falseon all common layout container types:Grid,StackPanel,Panel,WrapPanel,DockPanel,ItemsControl,ContentControl,ContentPresenter,Border,Decorator,Viewbox,ScrollContentPresenter,ItemsPresenter.LayoutTransformControloverridesClipToBoundsin its static constructor so it can't be beaten byApplication.Styles; aUserControl-scoped style is added toLayoutControlto win via style proximity.ClipToBounds=FalseonItemGridControlinner elements for belt-and-suspenders coverage.HorizontalAlignment/VerticalAlignment=Stretchto theButtoninTrackableItemControlso it fills its grid cell correctly.Test plan
?icons appear correctly over doors🤖 Generated with Claude Code