* Allow `TextSearch.TextBinding` on non-controls.
Allow setting `TextSearch.TextBinding` on non-controls: in particular I would like to be able to set it on (tree) data grid columns. For example:
```
<TreeDataGrid>
<TreeDataGridTemplateColumn TextSearch.TextBinding="{Binding Foo}">
<DataTemplate>
<TextBlock Text="{Binding Foo}"/>
</DataTemplate>
</TreeDataGridTemplateColumn>
</TreeDataGrid>
```
* Allow TextSearch.Text on non-controls
* Update API suppressions
* Rename TextSearch.GetText parameter
---------
Co-authored-by: Max Katz <maxkatz6@outlook.com>
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* test: verify ShowCore applies default icon when no custom icon is set
Adds a test that verifies Window.Show() applies the default icon via
SetIcon when no custom icon has been set. Currently fails because
ShowCore has no default icon logic — the fallback only exists in the
constructor binding where it eagerly loads the icon.
Relates to #20478
* fix: defer default icon loading from constructor to ShowCore
The default icon was eagerly loaded during Window construction via
CreatePlatformImplBinding, even when a custom icon would be set or no
icon was needed. This caused unnecessary I/O (assembly resource loading)
on every first Window instantiation.
Move the default icon fallback from the binding lambda to ShowCore,
so LoadDefaultIcon only runs when the window is actually shown and
no custom icon has been set.
Fixes#20478
* Don't tick with render loop when app is idle
* Update src/Avalonia.Base/Rendering/Composition/Transport/BatchStreamArrayPool.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* wip
* wip
* api diff
* fixes
* Address review: clear wakeupPending at tick start, guard CarbonEmissionsHack subscriptions
- Clear _wakeupPending at start of TimerTick so wakeups already processed
by the current tick don't force an unnecessary extra tick
- Guard CarbonEmissionsHack against duplicate subscriptions using a private
attached property
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix lock-order inversion in Add/Remove vs TimerTick
Move Wakeup() and Stop() calls outside the _items lock in Add/Remove
to prevent deadlock with TimerTick which acquires _timerLock then _items.
Add/Remove are UI-thread-only so the extracted logic remains safe.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: remove unused usings, guard double Stop(), fix SleepLoop extra frame
- Remove unused using directives from IRenderLoopTask.cs
- Guard TimerTick Stop() with _running check to prevent double Stop()
when Remove() already stopped the timer
- SleepLoopRenderTimer: use WaitOne(timeout) instead of Thread.Sleep
so Stop() can interrupt the sleep, and recheck _stopped before Tick
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DisplayLinkTimer foreground handler bypassing render loop state
Only resume the display link on WillEnterForeground if the timer was
calling Start() to avoid setting _stopped=false when the render loop
had the timer stopped.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DisplayLinkTimer thread safety, revert global NU5104 suppression
- Stop() now only sets _stopped flag; OnLinkTick() self-pauses the
CADisplayLink from the timer thread to avoid thread-affinity issues
- Revert NU5104 global suppression in SharedVersion.props
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Cap _ticksSinceLastCommit to prevent int overflow
Stop incrementing once it reaches CommitGraceTicks to prevent
wrapping negative and keeping the render loop awake indefinitely.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: remove Start/Stop from IRenderTimer, merge into Tick setter
Timer start/stop is now controlled entirely by setting the Tick
property: non-null starts, null stops. This eliminates the explicit
Start()/Stop() methods from IRenderTimer, making the API simpler.
DefaultRenderLoop controls the timer purely through Tick assignment
under its _timerLock. A new _hasItems flag tracks subscriber presence
since Tick is now transient (null when idle).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: address review comments on timer thread safety and guards
- ChoreographerTimer: add _frameCallbackActive guard to prevent double
PostFrameCallback from both Tick setter and SubscribeView
- ServerCompositor: cap _ticksSinceLastCommit at int.MaxValue
- SleepLoopRenderTimer: make _tick volatile, remove _stopped recheck
(guard moved to DefaultRenderLoop)
- DefaultRenderLoop: add _running check at tick start to drop late ticks
- ThreadProxyRenderTimer: add lock for internal state manipulation
- DisplayLinkTimer: add lock for all internal state manipulation
- Re-add NU5104 suppression to SharedVersion.props
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: make _hasItems volatile for cross-thread visibility
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: guard against redundant starts in DefaultRenderTimer, make _tick volatile across all timers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove CarbonEmissionsHack, revert iOS/Android timers to always-ticking
- Delete CarbonEmissionsHack class and its XAML reference
- Revert DisplayLinkTimer (iOS) to original always-ticking implementation
- Revert ChoreographerTimer (Android) to original always-ticking implementation
- Add TODO comments for future start/stop on RenderLoop request
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix DirectCompositionConnection WaitOne not respecting process exit cancellation
Use WaitHandle.WaitAny with both _wakeEvent and cts.Token.WaitHandle so
the loop can exit when ProcessExit fires while the timer is stopped.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* timers
* XML docs
* Cache delegate
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add update-api command
* Api diff command
* Missed flag
* Restrict commands running on fork PRs
* Add concurrency
* Filter github.event.comment.author_association even before workflow started
* Use steps.pr.outputs.sha
* Only push api/ changes
* Add failing tests for animations visibility behavior
* Dont trigger InternalStep when IsEffectivelyVisible is false.
* Fix a 6 year old mistake.
Dont spawn a new DoubleAnimator, instead just parse the target Transform object and do a SetValue call for the interpolated animation value.
* add comment and remove redundant else
* use LightweightSubject to avoid hammering the binding system with extra value frames from SetValue as @grokys suggested.
* whitespace
* remove unused namespace
* remove extra fields
* Implement animation pause on invisible and dispose on visual tree detach
* Implement animation pause on invisible and dispose on visual tree detach
* add tests
* check pause state and combo with IEV
* fix review comment
* Add failing tests for #18280 and #20845
Tests cover:
- TabItem child DataContext binding not resolving (#20845)
- DataContext binding not propagating to TabItem children (#20845)
- DataContext binding not surviving tab switch round-trip (#20845)
- UserControl content losing DataContext on tab switch (#18280)
- Content temporarily getting wrong DataContext when switching tabs
- Transition not applying new DataContext to old content
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix TabControl DataContext issues (#18280, #20845)
Add ContentPresenter.SetContentWithDataContext to atomically set Content
and DataContext, preventing the intermediate state where setting Content
to a Control clears DataContext and causes the content to briefly inherit
the wrong DataContext from higher up the tree.
TabControl.UpdateSelectedContent now uses this method, and the DataContext
subscription no longer applies the new container's DataContext to the old
content during page transitions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add tests for ContentTemplate with Control content DataContext
When a TabItem has a ContentTemplate and its Content is a Control, the
ContentPresenter should set DataContext to the content (so the template
can bind to the control's properties), not the TabItem's DataContext.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Only use SetContentWithDataContext when no ContentTemplate is set
When a ContentTemplate is present and content is a Control, the
ContentPresenter should set DataContext = content so the template can
bind to the control's properties. Only override DataContext with the
container's DataContext when there's no template (i.e. the presenter
displays the control directly).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Ensure that native control bounds are properly rounded when UseLayoutRounding is enabled.
This prevents alignment issues with Avalonia's visual tree, especially at non-integer scaling factors.
The calculation now uses LayoutHelper.RoundLayoutValue for each edge of the transformed rectangle,
matching how Avalonia rounds other layout elements.
* Send Page lifecycle events after page transitions
* Cleanup
* Moved the push lifecycle calls out of ExecutePushCore
---------
Co-authored-by: Javier Suárez Ruiz <javiersuarezruiz@hotmail.com>
* Fix TextBox validation error persisting when reverting to same valid value
When a TwoWay binding with validation had an error and the user set the
target back to the same value that was last successfully written to the
source, WriteTargetValueToSource() would bail out early because the
target value matched LeafNode.Value. This prevented WriteValueToSource()
from being called, so the validation error was never cleared.
Add an ErrorType check to the condition in WriteTargetValueToSource() so
that the write-through still happens when there is a pending validation
error, matching the pattern already used in WriteValueToSource() at
line 310.
Fixes#20534https://claude.ai/code/session_01LTinLuE1bsNKaLPuDSNuuw
* Add test for validation error clearing when reverting to same valid value
Reproduces the scenario from #20534 where a TwoWay binding with a
setter that throws on invalid values fails to clear the validation error
when the target is set back to the same value that was last successfully
written to the source.
https://claude.ai/code/session_01LTinLuE1bsNKaLPuDSNuuw
* Remove redundant checks in WriteTargetValueToSource()
* Add failing test for #20688
Unit test created from issue description
* Add a failing test for wrong CacheLength handling
All items would be realized which is obviously wrong
* fix test setup used StackPanel instead of expcected
VirtualizingStackPanel
* Make sure the test actually fails
* update comment
* Fix for focusedElement and focusedIndex
* add another unit test
* Fixes for new test cases
* Addressing Review
* Update tests to match new behavior
* only recycle focused element if it is not null
* Address review
* Address copilot review
* add failing test
* fix StartU estimation
* remove unused sample file
* Implemented new drawn window decorations API
TODO: check if it works on Win32, bring back titlebar automation peer
* Adjusting naming a bit
* Naming / configuration changes
* Various fixes
* popover fix?
* wip
* Address review
* Extra window roles
* WIP
* Fixed drawn titlebar automation
* Purge ExtendClientAreaChromeHints.
* Fixed dynamically enabling drawn decorations
* api diff
* Add automation IDs for drawn decorations buttons
* Resolved the issues
* build
* Retry a few times when Pager isn't available after test is finished
* Only do faulty test detection if asked
* duplicate package reference
* Try disabling faulty tests on appium1
* Fix ExtendClientAreaWindowTests
* Apply initial button states
* Enable CSD shadow for X11
* net8?
* Address review
* more review comments
* Moar review comments
* Extra hit-test checks
* Moar review
* Prefix integration test app exitfullscreen to avoid clashes
* Disable drawn decorations if parts = None
* Respect SystemDecorations value on mac in extend-client-area mode
* Tidy up logic a bit
* Adjust win32 tests to titlebar not being in the tree when CSD are not enabled
---------
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* move gesture events from Gestures to InputElement. Fix holding gesture interactions with context menu
* update api diff
* address review comments
* fix some test types
* rename Cancelled to Canceled
* update api diff
GetAbsoluteBounds() was using TransformToAABB only for the position but
then returning the untransformed Bounds.Size. This caused native controls
inside a Viewbox (or any parent with a visual transform) to be sized
incorrectly - the native window would appear at the right position but
at the wrong (unscaled) size.
Use the full transformed rect from TransformToAABB for both position and
size.
Fixes#13832
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
* Implement safe TypeCast expression handling
* Add reflection based (still AOT safe) Path.StreamTask and Path.StreamObservable
* Remove RequiresDynamicCode, as it's no longer true
* Stream bindings are not supported
* ObservableStreamPlugin.MatchesType should handle if type itself is observable
* Fix Cecil not finding generic methods
* Fix missing root automation peer in x11/atspi
* Root nodes are special case; fix GetIndexInParentAsync to handle root nodes since their parents == null.