Xaml Behaviors is a port of Windows UWP version of XAML Behaviors for Avalonia XAML.
Avalonia XAML Behaviors is an easy-to-use means of adding common and reusable interactivity to your Avalonia applications with minimal code. Avalonia port is available only for managed applications. Use of XAML Behaviors is governed by the MIT License.
First, clone the repository or download the latest zip.
git clone https://github.com/wieslawsoltes/Xaml.Behaviors.git
Open up a command-prompt and execute the commands:
.\build.ps1
Open up a terminal prompt and execute the commands:
./build.sh
Open up a terminal prompt and execute the commands:
./build.sh
Avalonia XamlBehaviors is delivered as a NuGet package.
You can find the packages here NuGet and install the package like this:
Install-Package Xaml.Behaviors
or by using nightly build feed:
- Add
https://www.myget.org/F/xamlbehaviors-nightly/api/v2
to your package sources - Alternative nightly build feed
https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json
- Update your package using
XamlBehaviors
feed
and install the package like this:
Install-Package Xaml.Behaviors -Pre
Package | Description |
---|---|
Xaml.Behaviors | Complete library of behaviors, actions and triggers for Avalonia applications. |
Xaml.Behaviors.Avalonia | Meta package that bundles all Avalonia XAML Behaviors for easy installation. |
Xaml.Behaviors.Interactivity | Foundation library providing base classes for actions, triggers and behaviors. |
Xaml.Behaviors.Interactions | Core collection of common triggers and actions for Avalonia. |
Xaml.Behaviors.Interactions.Custom | Custom behaviors and actions for common Avalonia controls. |
Xaml.Behaviors.Interactions.DragAndDrop | Behaviors that enable drag-and-drop support in Avalonia. |
Xaml.Behaviors.Interactions.Draggable | Draggable element behaviors for moving controls around. |
Xaml.Behaviors.Interactions.Events | Behaviors responding to Avalonia input and focus events. |
Xaml.Behaviors.Interactions.ReactiveUI | Behaviors integrating ReactiveUI navigation patterns. |
Xaml.Behaviors.Interactions.Responsive | Behaviors to assist with responsive and adaptive UI layouts. |
Xaml.Behaviors.Interactions.Scripting | Execute C# scripts at runtime to add dynamic behavior. |
The steps below show how a new user can attach their first behavior. These examples assume you have created an Avalonia application and want to enhance it with interactions.
- Install the package – open your NuGet package manager and add
Xaml.Behaviors
or any of the interaction packages such asXaml.Behaviors.Interactions
. - Declare the namespace – reference the default Avalonia namespace and the XAML Behaviors namespace at the top of your XAML file.
- Attach a behavior – use the
Interaction.Behaviors
attached property to add behaviors to your controls.
Here is a minimal example:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Content="Click">
<Interaction.Behaviors>
<EventTriggerBehavior EventName="Click">
<InvokeCommandAction Command="{Binding ClickCommand}" />
</EventTriggerBehavior>
</Interaction.Behaviors>
</Button>
</UserControl>
The examples below walk through typical scenarios where behaviors remove the need for boilerplate code.
- React to data changes – monitor a bound property and update another control automatically.
- Handle lifecycle events – execute actions when a control appears or is loaded.
In XAML this looks like:
<!-- Change text based on slider value -->
<TextBlock x:Name="Output">
<Interaction.Behaviors>
<DataTriggerBehavior Binding="{Binding #Slider.Value}" ComparisonCondition="GreaterThan" Value="50">
<ChangePropertyAction PropertyName="Text" Value="High" />
</DataTriggerBehavior>
<DataTriggerBehavior Binding="{Binding #Slider.Value}" ComparisonCondition="LessThanOrEqual" Value="50">
<ChangePropertyAction PropertyName="Text" Value="Low" />
</DataTriggerBehavior>
</Interaction.Behaviors>
</TextBlock>
<!-- Focus a control when it appears -->
<TextBox>
<Interaction.Behaviors>
<EventTriggerBehavior EventName="Loaded">
<FocusControlAction />
</EventTriggerBehavior>
</Interaction.Behaviors>
</TextBox>
Behind the scenes behaviors rely on Avalonia's attached property and reactive object model. When you set Interaction.Behaviors
on any AvaloniaObject
, Avalonia's property system fires a property changed notification. The Interaction
helper class listens for these changes and attaches each entry of the BehaviorCollection
to the target control. Each behavior implements IAttachedObject
and inherits from Behavior
or Behavior<T>
which provide OnAttached
and OnDetaching
methods. These methods are invoked by the framework so the behavior can subscribe to routed events, bind to properties or manipulate the visual tree. Because behaviors live in a collection you can add or remove them dynamically at runtime just like any other Avalonia property.
Triggers and actions follow the same pattern. A Trigger
holds a collection of IAction
objects. When the trigger condition is met—for example an event fires or a bound property changes—the trigger iterates its actions and calls their Execute
method. Everything relies on base types such as AvaloniaObject
, the binding engine and the routing/event system, so no reflection or markup extension magic is needed. Understanding these building blocks helps when creating custom behaviors or when troubleshooting how they interact with your controls.
Behaviors can also be defined in styles or extended by creating your own implementations. Advanced scenarios typically involve keeping XAML clean or encapsulating reusable interaction logic.
- Attach behaviors from styles – ideal when the same behavior should apply to multiple controls.
- Create custom behaviors – extend
Behavior<T>
to implement unique interactions.
Below is a walkthrough of both approaches.
Defining behaviors in a style
<Style Selector="Button.alert">
<Setter Property="(Interaction.Behaviors)">
<BehaviorCollectionTemplate>
<BehaviorCollection>
<EventTriggerBehavior EventName="PointerEnter">
<ChangePropertyAction PropertyName="Background" Value="Red" />
</EventTriggerBehavior>
</BehaviorCollection>
</BehaviorCollectionTemplate>
</Setter>
</Style>
To use the style, assign the alert
class to any Button
and it will change its background when the pointer enters the control.
Creating a custom behavior
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Xaml.Interactivity;
public class RotateOnClickBehavior : Behavior<Button>
{
protected override void OnAttached()
{
AssociatedObject.PointerPressed += OnPointerPressed;
}
protected override void OnDetaching()
{
AssociatedObject.PointerPressed -= OnPointerPressed;
}
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
AssociatedObject.RenderTransform = new RotateTransform(45);
}
}
- Derive from
Behavior<T>
– specify the control type the behavior will attach to. - Override
OnAttached
andOnDetaching
– wire up and remove event handlers or other logic. - Consume the behavior – add it in XAML like any built‑in behavior or through a style.
Custom triggers and actions follow the same pattern—derive from Trigger
or Action
and override the relevant methods. Use these techniques to build a library of reusable interactions tailored to your application.
This section provides an overview of all available classes and their purpose in Avalonia XAML Behaviors. The classes are grouped into logical categories based on their functionality.
-
AddClassAction (Sample) Adds a style class to a control’s class collection, making it easy to change the appearance dynamically.
-
ChangeAvaloniaPropertyAction (Sample) Changes the value of an Avalonia property on a target object at runtime.
-
CloseNotificationAction (Sample) Closes an open notification, for example, from a notification control.
-
FocusControlAction (Sample) Sets the keyboard focus on a specified control or the associated control.
-
HideControlAction (Sample) Hides a control by setting its
IsVisible
property to false. -
ShowControlAction (Sample) Shows a control and gives it focus when executed.
-
DelayedShowControlAction (Sample) Shows a control after waiting for a specified delay.
-
PopupAction (Sample) Displays a popup window for showing additional UI content.
-
ShowPopupAction (Sample) Opens an existing popup for a control.
-
HidePopupAction (Sample) Closes an existing popup associated with a control.
-
ShowFlyoutAction (Sample) Shows a flyout attached to a control or specified explicitly.
-
HideFlyoutAction (Sample) Hides a flyout attached to a control or specified explicitly.
-
RemoveClassAction (Sample) Removes a style class from a control’s class collection.
-
RemoveElementAction (Sample) Removes a control from its parent container when executed.
-
MoveElementToPanelAction (No sample available.) Moves a control to the specified panel.
-
ShowContextMenuAction (Sample) Displays a control's context menu programmatically.
-
SplitViewTogglePaneAction (Sample) Toggles the
IsPaneOpen
state of aSplitView
. -
SetViewModelPropertyAction (Sample) Sets a property on the DataContext to a specified value.
-
IncrementViewModelPropertyAction (Sample) Adds a numeric delta to a view model property.
-
ToggleViewModelBooleanAction (Sample) Toggles a boolean view model property.
-
FadeInBehavior (Sample) Animates the fade-in effect for the associated element, gradually increasing its opacity.
-
StartAnimationAction (Sample) Triggers a defined animation on the target control when executed.
-
AnimateOnAttachedBehavior (Sample) Runs a specified animation when the control appears in the visual tree.
-
StartBuiltAnimationAction (Sample) Creates an animation in code using an
IAnimationBuilder
and starts it. -
RunAnimationTrigger (Sample) Runs an animation and invokes actions when it completes.
-
IAnimationBuilder (Sample) Interface for providing animations from view models in an MVVM friendly way.
-
PlayAnimationBehavior (Sample) Runs a supplied animation automatically when the control appears in the visual tree.
-
BeginAnimationAction (Sample) Starts an animation on a specified control, allowing the target to be chosen explicitly.
-
AnimationCompletedTrigger (Sample) Plays an animation and invokes actions once the animation finishes running.
- TransitionsBehavior (Sample)
Sets the
Transitions
collection on the associated control when attached. - AddTransitionAction (Sample)
Adds a transition to a control's
Transitions
collection. - RemoveTransitionAction (Sample)
Removes a transition from a control's
Transitions
collection. - ClearTransitionsAction (Sample) Clears all transitions from a control.
- TransitionsChangedTrigger (Sample)
Triggers actions when the
Transitions
property of a control changes.
- FocusAutoCompleteBoxTextBoxBehavior (Sample) Ensures the text box within an AutoCompleteBox gets focus automatically.
- AutoCompleteBoxOpenDropDownOnFocusBehavior (Sample) Opens the AutoCompleteBox drop-down when the control receives focus.
- AutoCompleteBoxSelectionChangedTrigger (Sample) Triggers actions when the AutoCompleteBox selection changes.
- ClearAutoCompleteBoxSelectionAction (Sample) Clears the AutoCompleteBox selection and text.
- AutomationNameBehavior (Sample) Applies an automation name to the associated control.
- AutomationNameChangedTrigger (Sample) Triggers actions when the automation name of the control changes.
- SetAutomationIdAction (Sample) Sets the automation ID on a target control.
- CarouselKeyNavigationBehavior (Sample) Enables keyboard navigation for a Carousel using arrow keys.
- CarouselNextAction (Sample) Advances the target Carousel to the next page.
- CarouselPreviousAction (Sample) Moves the target Carousel to the previous page.
- CarouselSelectionChangedTrigger (Sample) Triggers actions when the Carousel selection changes.
- AddRangeAction (Sample)
Adds multiple items to an
IList
. - RemoveRangeAction (Sample)
Removes multiple items from an
IList
. - ClearCollectionAction (Sample)
Clears all items from an
IList
. - CollectionChangedBehavior (Sample) Invokes actions based on collection change notifications.
- CollectionChangedTrigger (Sample) Triggers actions whenever the observed collection changes.
- TabControlKeyNavigationBehavior (Sample) Enables keyboard navigation for a TabControl using arrow keys.
- TabControlNextAction (Sample) Advances the target TabControl to the next tab.
- TabControlPreviousAction (Sample) Moves the target TabControl to the previous tab.
- TabControlSelectionChangedTrigger (Sample) Triggers actions when the TabControl selection changes.
-
ButtonClickEventTriggerBehavior (Sample) Listens for a button’s click event and triggers associated actions.
-
ButtonExecuteCommandOnKeyDownBehavior (Sample) Executes a command when a specified key is pressed while the button is focused.
-
ButtonHideFlyoutBehavior (Sample) Hides an attached flyout when the button is interacted with.
-
ButtonHideFlyoutOnClickBehavior (Sample) Automatically hides the flyout attached to the button when it is clicked.
-
ButtonHidePopupOnClickBehavior (Sample) Automatically closes the popup containing the button when it is clicked.
-
ClearClipboardAction (Sample) Clears all contents from the system clipboard.
-
GetClipboardDataAction (Sample) Retrieves data from the clipboard in a specified format.
-
GetClipboardFormatsAction (Sample) Retrieves the list of available formats from the clipboard.
-
GetClipboardTextAction (Sample) Retrieves plain text from the clipboard.
-
SetClipboardDataObjectAction (Sample) Places a custom data object onto the clipboard.
-
SetClipboardTextAction (Sample) Places text onto the clipboard.
- NotificationManagerBehavior (Sample) Creates a notification manager for a window when attached.
- ShowNotificationAction (Sample) Shows a notification using an attached notification manager.
- ShowInformationNotificationAction (Sample) Displays an information notification via a manager.
- ShowSuccessNotificationAction (Sample) Displays a success notification via a manager.
- ShowWarningNotificationAction (Sample) Displays a warning notification via a manager.
- ShowErrorNotificationAction (Sample) Displays an error notification via a manager.
-
SelectingItemsControlBehavior (Sample) Animates selection transitions in items controls such as ListBox or TabControl.
-
SlidingAnimation (Sample) Provides static methods to apply sliding animations (from left, right, top, or bottom) to a control.
-
FluidMoveBehavior (Sample) Animates layout changes of a control or its children.
- ContextDialogBehavior (Sample) Manages a popup-based context dialog for a control.
- ShowContextDialogAction (Sample) Opens a context dialog using a specified behavior.
- HideContextDialogAction (Sample) Closes a context dialog using a specified behavior.
- ContextDialogOpenedTrigger (Sample) Triggers actions when a context dialog is opened.
- ContextDialogClosedTrigger (Sample) Triggers actions when a context dialog is closed.
-
BindPointerOverBehavior (Sample) Two‑way binds a boolean property to a control’s pointer-over state.
-
BindTagToVisualRootDataContextBehavior (Sample) Binds the control’s Tag property to the DataContext of its visual root, enabling inherited data contexts.
-
BoundsObserverBehavior (Sample) Observes a control’s bounds changes and updates two‑way bound Width and Height properties.
-
DragControlBehavior (Sample) Enables a control to be moved (dragged) around by changing its RenderTransform during pointer events.
-
HideAttachedFlyoutBehavior (Sample) Hides a flyout that is attached to a control when a condition is met.
-
HideOnKeyPressedBehavior (Sample) Hides the target control when a specified key is pressed.
-
HideOnLostFocusBehavior (Sample) Hides the target control when it loses focus.
-
InlineEditBehavior (Sample) Toggles display and edit controls to enable in-place text editing.
-
ShowPointerPositionBehavior (Sample) Displays the current pointer position (x, y coordinates) in a TextBlock for debugging or UI feedback.
-
SetCursorBehavior (Sample) Applies a custom cursor to the associated control.
-
PointerOverCursorBehavior (Sample) Changes the cursor while the pointer is over the control and resets it on exit.
-
SetCursorFromProviderBehavior (Sample) Uses an
ICursorProvider
implementation to supply the cursor for the associated control. -
SizeChangedTrigger (Sample) Triggers actions when the associated control's size changes.
- PointerEventArgsConverter (Sample) Converts pointer event arguments into a tuple (x, y) representing the pointer’s location.
-
ActualThemeVariantChangedBehavior (Sample) A base class for behaviors that react to theme variant changes (e.g. switching from light to dark mode).
-
ActualThemeVariantChangedTrigger (Sample) Triggers actions when the actual theme variant of a control changes.
-
ThemeVariantBehavior (Sample) Applies a specific theme variant to the associated control.
-
ThemeVariantTrigger (Sample) Triggers actions when the theme variant of a control changes.
-
SetThemeVariantAction (Sample) Sets the requested theme variant on a target control.
-
AttachedToLogicalTreeBehavior (Sample) A base class for behaviors that require notification when the associated object is added to the logical tree.
-
AttachedToLogicalTreeTrigger (Sample) Triggers actions when an element is attached to the logical tree.
-
AttachedToVisualTreeBehavior (Sample) A base class for behaviors that depend on the control being attached to the visual tree.
-
AttachedToVisualTreeTrigger (Sample) Triggers actions when the associated element is added to the visual tree.
-
BindingBehavior (Sample) Establishes a binding on a target property using an Avalonia binding.
-
BindingTriggerBehavior (Sample) Monitors a binding’s value and triggers actions when a specified condition is met.
-
CallMethodAction (Sample) Invokes a method on a target object when the action is executed.
-
ChangePropertyAction (Sample) Changes a property on a target object to a new value using type conversion if needed.
-
LaunchUriOrFileAction (Sample) Opens a URI or file using the default associated application.
-
DataContextChangedBehavior (Sample) A base class for behaviors that react to changes in the DataContext.
-
DataContextChangedTrigger (Sample) Triggers actions when the DataContext of a control changes.
-
DataTriggerBehavior (Sample) Evaluates a data binding against a given condition and triggers actions when the condition is true.
-
DataTrigger (Sample) Performs actions when the bound data meets a specified condition.
-
PropertyChangedTrigger (Sample) Triggers actions when a property value changes.
-
ViewModelPropertyChangedTrigger (Sample) Invokes actions when a DataContext property changes.
-
DetachedFromLogicalTreeTrigger (Sample) Triggers actions when the control is removed from the logical tree.
-
DetachedFromVisualTreeTrigger (Sample) Triggers actions when the control is removed from the visual tree.
-
DisposingBehavior (Sample) A base class for behaviors that manage disposable resources automatically.
-
DisposingTrigger (Sample) A base class for triggers that need to dispose of resources when detached.
-
DisposableAction (Sample) Executes a delegate when the object is disposed.
-
EventTriggerBehavior (Sample) Listens for a specified event on the associated object and triggers actions accordingly.
-
EventTrigger (Sample) Executes its actions when the configured event is raised.
-
TimerTrigger (Sample) Invokes actions repeatedly after a set interval.
-
InitializedBehavior (Sample) A base class for behaviors that execute code when the associated object is initialized.
-
InitializedTrigger (Sample) Triggers actions once the control is initialized.
-
InvokeCommandAction (Sample) Executes a bound ICommand when the action is invoked.
-
InvokeCommandActionBase (Sample) The base class for actions that invoke commands, with support for parameter conversion.
-
LoadedBehavior (Sample) A base class for behaviors that run when a control is loaded into the visual tree.
-
SetViewModelPropertyOnLoadBehavior (Sample) Sets a view model property when the associated control is loaded.
-
LoadedTrigger (No sample available.) Triggers actions when the control’s Loaded event fires.
-
DelayedLoadBehavior (Sample) Hides the control then shows it after a specified delay when attached to the visual tree.
-
DelayedLoadTrigger (Sample) Invokes actions after the control is loaded and a delay period expires.
-
ResourcesChangedBehavior (Sample) A base class for behaviors that respond when a control’s resources change.
-
ResourcesChangedTrigger (Sample) Triggers actions when the control’s resources are modified.
-
RoutedEventTriggerBase (Sample) A base class for triggers that listen for a routed event and execute actions.
-
RoutedEventTriggerBase (No sample available.) Generic version of RoutedEventTriggerBase for strongly typed routed event args.
-
RoutedEventTriggerBehavior (Sample) Listens for a routed event on the associated object and triggers its actions.
-
UnloadedTrigger (Sample) Triggers actions when the control is unloaded from the visual tree.
-
ValueChangedTriggerBehavior (Sample) Triggers actions when the value of a bound property changes.
-
IfElseTrigger (Sample) Executes one collection of actions when a condition is true and another when it is false.
-
ContextDragBehavior (Sample) Enables drag operations using a “context” (data payload) that is carried during the drag–drop operation.
-
ContextDragWithDirectionBehavior (Sample) Starts a drag operation and includes the drag direction in the data object.
-
ContextDropBehavior (Sample) Handles drop events and passes context data between the drag source and drop target.
-
DropHandlerBase (No sample available.) Provides common helper methods (move, swap, insert) for implementing custom drop logic.
-
IDragHandler (No sample available.) Interface for classes that handle additional logic before and after a drag–drop operation.
-
IDropHandler (No sample available.) Interface for classes that implement validation and handling of drop operations.
-
DropBehaviorBase (No sample available.) Base class for behaviors that handle drag-and-drop events and execute commands.
-
ContextDragBehaviorBase (No sample available.) Base class for context drag behaviors that initiate a drag using context data.
-
ContextDropBehaviorBase (No sample available.) Base class for context drop behaviors handling dropped context data.
-
DragAndDropEventsBehavior (No sample available.) Abstract behavior used to attach handlers for drag-and-drop events.
-
FilesDropBehavior (Sample) Executes a command with a collection of dropped files.
-
ContentControlFilesDropBehavior (Sample) Executes a command with dropped files on a ContentControl.
-
TextDropBehavior (Sample) Executes a command with dropped text.
-
TypedDragBehaviorBase (No sample available.) Base class for drag behaviors working with a specific data type.
-
TypedDragBehavior (Sample) Provides drag behavior for items of a specified data type.
-
PanelDragBehavior (Sample) Starts drag operations using the dragged control as context so it can be moved between panels.
-
PanelDropBehavior (Sample) Accepts dragged controls and inserts them into the target panel.
-
CanvasDragBehavior (No sample available.) Enables a control to be dragged within a Canvas by updating its RenderTransform based on pointer movements.
-
GridDragBehavior (Sample) Allows grid cells (or items) to be swapped or repositioned by dragging within a Grid layout.
-
ItemDragBehavior (No sample available.) Enables reordering of items in an ItemsControl by dragging and dropping items.
-
MouseDragElementBehavior (Sample) Allows an element to be dragged using the mouse.
-
MultiMouseDragElementBehavior (Sample) Supports dragging multiple elements simultaneously with the mouse.
-
SelectionAdorner (No sample available.) A visual adorner used to indicate selection or to show drag outlines during drag–drop operations.
-
InteractiveBehaviorBase (No sample available.) Base class for behaviors that listen to UI events, providing common functionality for event triggers.
-
InteractionTriggerBehavior (Sample) Base behavior for creating custom event-based triggers.
-
DoubleTappedEventBehavior (No sample available.) Listens for double-tap events and triggers its actions when detected.
-
GotFocusEventBehavior (No sample available.) Executes actions when the associated control receives focus.
-
KeyDownEventBehavior (No sample available.) Monitors key down events and triggers actions when the specified key is pressed.
-
KeyUpEventBehavior (No sample available.) Monitors key up events and triggers actions when the specified key is released.
-
LostFocusEventBehavior (No sample available.) Triggers actions when the control loses focus.
-
PointerCaptureLostEventBehavior (No sample available.) Listens for events when pointer capture is lost and triggers associated actions.
-
PointerEnteredEventBehavior (No sample available.) Triggers actions when the pointer enters the bounds of a control.
-
PointerEventsBehavior (No sample available.) A base class that simplifies handling of pointer events (pressed, moved, released).
-
PointerExitedEventBehavior (No sample available.) Triggers actions when the pointer exits a control.
-
PointerMovedEventBehavior (No sample available.) Triggers actions when the pointer moves over a control.
-
PointerPressedEventBehavior (No sample available.) Triggers actions on pointer press events.
-
PointerReleasedEventBehavior (No sample available.) Triggers actions on pointer release events.
-
PointerWheelChangedEventBehavior (No sample available.) Triggers actions when the pointer wheel (scroll) changes.
-
RightTappedEventBehavior (No sample available.) Triggers actions when the control is right-tapped.
-
ScrollGestureEndedEventBehavior (No sample available.) Triggers actions when a scroll gesture ends.
-
ScrollGestureEventBehavior (No sample available.) Monitors scroll gestures and triggers actions when they occur.
-
TappedEventBehavior (No sample available.) Triggers actions on simple tap events.
-
TextInputEventBehavior (No sample available.) Listens for text input events and triggers actions accordingly.
-
TextInputMethodClientRequestedEventBehavior (No sample available.) Triggers actions when a text input method client is requested (for virtual keyboards, etc.).
- DoubleTappedEventTrigger (Sample) Triggers actions when a double-tap gesture occurs.
- GotFocusEventTrigger (Sample) Triggers actions when the control receives focus.
- KeyDownEventTrigger (Sample) Triggers actions when a key is pressed.
- KeyUpEventTrigger (Sample) Triggers actions when a key is released.
- LostFocusEventTrigger (Sample) Triggers actions when the control loses focus.
- PointerCaptureLostEventTrigger (Sample) Triggers actions when pointer capture is lost.
- PointerEnteredEventTrigger (Sample) Triggers actions when the pointer enters the control.
- PointerEventsTrigger (No sample available.) Triggers actions for pointer press, move, and release events.
- PointerExitedEventTrigger (Sample) Triggers actions when the pointer exits the control.
- PointerMovedEventTrigger (Sample) Triggers actions when the pointer moves.
- PointerPressedEventTrigger (Sample) Triggers actions when the pointer is pressed.
- PointerReleasedEventTrigger (Sample) Triggers actions when the pointer is released.
- PointerWheelChangedEventTrigger (Sample) Triggers actions when the pointer wheel changes.
- RightTappedEventTrigger (Sample) Triggers actions on a right-tap gesture.
- ScrollGestureEndedEventTrigger (Sample) Triggers actions when a scroll gesture ends.
- ScrollGestureEventTrigger (Sample) Triggers actions during a scroll gesture.
- TappedEventTrigger (Sample) Triggers actions when the control is tapped.
- TextInputEventTrigger (Sample) Triggers actions on text input events.
- TextInputMethodClientRequestedEventTrigger (Sample) Triggers actions when a text input method client is requested.
- PopupOpenedTrigger (Sample) Triggers actions when a popup is opened.
- PopupClosedTrigger (Sample) Triggers actions when a popup is closed.
- DragEnterEventTrigger (Sample) Triggers actions when a drag operation enters the element.
- DragLeaveEventTrigger (No sample available.) Triggers actions when a drag operation leaves the element.
- DragOverEventTrigger (Sample) Triggers actions while a drag is over the element.
- DropEventTrigger (Sample) Triggers actions when an item is dropped on the element.
-
ExecuteCommandBehaviorBase (No sample available.) Provides the core functionality for executing a command from within a behavior.
-
ExecuteCommandOnKeyBehaviorBase (No sample available.) A base class for command behaviors triggered by key events.
-
ExecuteCommandRoutedEventBehaviorBase (No sample available.) A base class for command behaviors that respond to routed events.
-
ExecuteCommandOnActivatedBehavior (No sample available.) Executes a command when the main window (or target window) is activated.
-
ExecuteCommandOnDoubleTappedBehavior (Sample) Executes a command when the associated control is double-tapped.
-
ExecuteCommandOnGotFocusBehavior (No sample available.) Executes a command when the control gains focus.
-
ExecuteCommandOnHoldingBehavior (No sample available.) Executes a command when a holding (long press) gesture is detected.
-
ExecuteCommandOnKeyDownBehavior (Sample) Executes a command in response to a key down event matching a specified key or gesture.
-
ExecuteCommandOnKeyUpBehavior (No sample available.) Executes a command in response to a key up event matching a specified key or gesture.
-
ExecuteCommandOnLostFocusBehavior (No sample available.) Executes a command when the control loses focus.
-
ExecuteCommandOnPinchBehavior (No sample available.) Executes a command when a pinch gesture is in progress.
-
ExecuteCommandOnPinchEndedBehavior (No sample available.) Executes a command when a pinch gesture ends.
-
ExecuteCommandOnPointerCaptureLostBehavior (No sample available.) Executes a command when pointer capture is lost from the control.
-
ExecuteCommandOnPointerEnteredBehavior (Sample) Executes a command when the pointer enters the control’s area.
-
ExecuteCommandOnPointerExitedBehavior (No sample available.) Executes a command when the pointer exits the control’s area.
-
ExecuteCommandOnPointerMovedBehavior (No sample available.) Executes a command when the pointer moves over the control.
-
ExecuteCommandOnPointerPressedBehavior (Sample) Executes a command when the pointer is pressed on the control.
-
ExecuteCommandOnPointerReleasedBehavior (No sample available.) Executes a command when the pointer is released over the control.
-
ExecuteCommandOnPointerTouchPadGestureMagnifyBehavior (No sample available.) Executes a command during a touchpad magnify gesture.
-
ExecuteCommandOnPointerTouchPadGestureRotateBehavior (No sample available.) Executes a command during a touchpad rotation gesture.
-
ExecuteCommandOnPointerTouchPadGestureSwipeBehavior (No sample available.) Executes a command during a touchpad swipe gesture.
-
ExecuteCommandOnPointerWheelChangedBehavior (No sample available.) Executes a command when the pointer wheel delta changes.
-
ExecuteCommandOnPullGestureBehavior (No sample available.) Executes a command when a pull gesture is detected.
-
ExecuteCommandOnPullGestureEndedBehavior (No sample available.) Executes a command when a pull gesture ends.
-
ExecuteCommandOnRightTappedBehavior (No sample available.) Executes a command when the control is right-tapped.
-
ExecuteCommandOnScrollGestureBehavior (No sample available.) Executes a command during a scroll gesture.
-
ExecuteCommandOnScrollGestureEndedBehavior (No sample available.) Executes a command when a scroll gesture ends.
-
ExecuteCommandOnScrollGestureInertiaStartingBehavior (No sample available.) Executes a command when the inertia phase of a scroll gesture starts.
-
ExecuteCommandOnTappedBehavior (No sample available.) Executes a command when a tap event occurs.
-
ExecuteCommandOnTextInputBehavior (No sample available.) Executes a command in response to text input events.
-
ExecuteCommandOnTextInputMethodClientRequestedBehavior (No sample available.) Executes a command when text input method (virtual keyboard) is requested.
-
InvokeCommandBehaviorBase (No sample available.) The base class that supports converting parameters and invoking a bound command.
- ButtonUploadFileBehavior (No sample available.) Opens a file dialog and uploads the selected file when the button is clicked.
- UploadFileBehaviorBase (No sample available.) Base behavior for uploading a file to a specified URL.
- UploadFileAction (Sample) Uploads a file asynchronously and invokes a command when finished.
- UploadCompletedTrigger (Sample) Invokes actions when an upload is marked complete.
-
AutoFocusBehavior (Sample) Automatically sets the focus on the associated control when it is loaded.
-
FocusBehavior (Sample) Exposes a two‑way bindable IsFocused property to control focus state.
-
FocusBehaviorBase (No sample available.) Provides a base implementation for focus behaviors, including support for navigation methods and key modifiers.
-
FocusControlBehavior (Sample) Forces focus onto a specified control when triggered.
-
FocusOnAttachedBehavior (Sample) Immediately focuses the control when the behavior is attached.
-
FocusOnAttachedToVisualTreeBehavior (Sample) Focuses the control as soon as it is attached to the visual tree.
-
FocusOnPointerMovedBehavior (Sample) Sets focus on the control when pointer movement is detected.
-
FocusOnPointerPressedBehavior (Sample) Focuses the control when a pointer press event occurs.
-
FocusSelectedItemBehavior (Sample) Focuses the currently selected item in an ItemsControl.
-
DoubleTappedGestureTrigger (No sample available.) Triggers actions when a double-tap gesture is detected.
-
HoldingGestureTrigger (No sample available.) Triggers actions when a holding (long press) gesture is detected.
-
PinchEndedGestureTrigger (No sample available.) Triggers actions when a pinch gesture has ended.
-
PinchGestureTrigger (No sample available.) Triggers actions during a pinch gesture.
-
PointerTouchPadGestureMagnifyGestureTrigger (No sample available.) Triggers actions during a touchpad magnification gesture.
-
PointerTouchPadGestureRotateGestureTrigger (No sample available.) Triggers actions during a touchpad rotation gesture.
-
PointerTouchPadGestureSwipeGestureTrigger (No sample available.) Triggers actions during a touchpad swipe gesture.
-
PullGestureEndedGestureTrigger (No sample available.) Triggers actions when a pull gesture ends.
-
PullGestureGestureTrigger (No sample available.) Triggers actions during a pull gesture.
-
RightTappedGestureTrigger (No sample available.) Triggers actions on a right-tap gesture.
-
ScrollGestureEndedGestureTrigger (No sample available.) Triggers actions when a scroll gesture completes.
-
ScrollGestureGestureTrigger (No sample available.) Triggers actions during a scroll gesture.
-
ScrollGestureInertiaStartingGestureTrigger (No sample available.) Triggers actions when the inertia phase of a scroll gesture begins.
-
TappedGestureTrigger (No sample available.) Triggers actions on a simple tap gesture.
- PathIconDataBehavior (Sample) Sets the Data property of a PathIcon when attached.
- SetPathIconDataAction (Sample) Changes the Data of a PathIcon when executed.
- PathIconDataChangedTrigger (Sample) Triggers actions when a PathIcon's Data changes.
-
CapturePointerAction (Sample) Captures the pointer (mouse, touch) to a target control so that subsequent pointer events are routed there.
-
ReleasePointerCaptureAction (Sample) Releases a previously captured pointer from the control.
-
SetCursorFromProviderAction (Sample) Sets the cursor of a control using a cursor created by an
ICursorProvider
. -
SetCursorAction (Sample) Sets the cursor of a control to a predefined cursor.
-
SetEnabledAction (Sample) Enables or disables the associated control.
-
HideToolTipAction (Sample) Hides the ToolTip of the target control.
-
SetToolTipTipAction (Sample) Sets the ToolTip's tip text on the associated or target control.
-
ShowToolTipAction (Sample) Shows the ToolTip for the associated or target control.
-### InputElement Triggers
-
DoubleTappedTrigger (Sample) Listens for a double-tap event and executes its actions.
-
GotFocusTrigger (Sample) Triggers actions when the control receives focus.
-
HoldingTrigger (Sample) Triggers actions when a holding gesture is detected.
-
KeyDownTrigger (Sample) Listens for key down events and triggers actions if the pressed key (or gesture) matches the specified criteria.
-
KeyGestureTrigger (Sample) Triggers actions based on a specified key gesture.
-
KeyTrigger (Sample) Listens for key down or key up events and triggers actions when the configured key or gesture occurs.
-
KeyUpTrigger (Sample) Listens for key up events and triggers actions when conditions are met.
-
LostFocusTrigger (Sample) Triggers actions when the control loses focus.
-
PointerCaptureLostTrigger (Sample) Triggers actions when pointer capture is lost by the control.
-
PointerEnteredTrigger (Sample) Triggers actions when the pointer enters the control’s area.
-
PointerExitedTrigger (Sample) Triggers actions when the pointer exits the control’s area.
-
PointerMovedTrigger (Sample) Triggers actions on pointer movement over the control.
-
PointerPressedTrigger (Sample) Triggers actions when the pointer is pressed on the control.
-
PointerReleasedTrigger (Sample) Triggers actions when the pointer is released on the control.
-
PointerWheelChangedTrigger (Sample) Triggers actions on mouse wheel (or equivalent) changes.
-
TappedTrigger (Sample) Triggers actions on a tap event.
-
ToolTipOpeningTrigger (Sample) Triggers actions when a tooltip is about to open.
-
ToolTipClosingTrigger (Sample) Triggers actions when a tooltip is closing.
-
TextInputMethodClientRequestedTrigger (Sample) Triggers actions when a text input method (virtual keyboard) is requested.
-
TextInputTrigger (Sample) Triggers actions on text input events.
- IWriteableBitmapRenderer (No sample available.) Defines a method used to render into a WriteableBitmap so view models can supply drawing logic.
- WriteableBitmapRenderBehavior (Sample) Creates a writeable bitmap and updates it using a renderer on a timer.
- WriteableBitmapRenderAction (No sample available.) Invokes a renderer to update a writeable bitmap.
- WriteableBitmapTimerTrigger (No sample available.) Fires its actions on a timer and passes the writeable bitmap as a parameter.
- WriteableBitmapBehavior (Sample) Creates a writeable bitmap and renders it once or on demand without animation.
- WriteableBitmapTrigger (No sample available.) Manually executes its actions with the provided writeable bitmap when triggered.
- IRenderTargetBitmapRenderer (No sample available.) Defines a method used to render into a RenderTargetBitmap.
- IRenderTargetBitmapSimpleRenderer (No sample available.) Provides a simple rendering method for StaticRenderTargetBitmapBehavior.
- RenderRenderTargetBitmapAction (Sample) Invokes IRenderTargetBitmapRenderHost.Render on the specified target.
- RenderTargetBitmapBehavior (Sample) Creates and updates a RenderTargetBitmap via a renderer.
- StaticRenderTargetBitmapBehavior (Sample) Draws once into a RenderTargetBitmap and assigns it to the associated Image.
- RenderTargetBitmapTrigger (No sample available.) Triggers actions when RenderTargetBitmap rendering completes.
-
ItemNudgeDropBehavior (No sample available.) Provides “nudge” effects for items in an ItemsControl during drag–drop reordering.
-
ItemsControlContainerClearingTrigger (No sample available.) Triggers actions when the ItemsControl clears its container(s).
-
ItemsControlContainerEventsBehavior (No sample available.) A base behavior that listens for container events (prepared, index changed, clearing) on an ItemsControl.
-
ItemsControlContainerIndexChangedTrigger (No sample available.) Triggers actions when the index of an item’s container changes.
-
ItemsControlContainerPreparedTrigger (No sample available.) Triggers actions when a container for an item is prepared.
-
ItemsControlPreparingContainerTrigger (No sample available.) Executes actions when the ItemsControl raises the PreparingContainer event.
-
ScrollToItemBehavior (No sample available.) Automatically scrolls the ItemsControl to make a specified item visible.
-
ScrollToItemIndexBehavior (No sample available.) Scrolls to a specific item index in the ItemsControl.
-
AddItemToItemsControlAction (Sample) Adds an item to an ItemsControl's collection.
-
InsertItemToItemsControlAction (Sample) Inserts an item at a specific index in an ItemsControl.
-
ClearItemsControlAction (Sample) Clears all items from an ItemsControl.
-
RemoveItemInItemsControlAction (Sample) Removes the specified item from an ItemsControl.
-
ListBoxSelectAllBehavior (No sample available.) Selects all items in a ListBox when the behavior is attached.
-
RemoveItemInListBoxAction (Sample) Removes the specified item from a ListBox.
-
ListBoxUnselectAllBehavior (No sample available.) Clears the selection in a ListBox.
- SelectListBoxItemOnPointerMovedBehavior (No sample available.) Automatically selects a ListBoxItem when the pointer moves over it.
- InlineEditBehavior (Sample) Toggles between a display element and a TextBox editor to enable inline editing (activated by double-tap or F2; ends on Enter, Escape, or losing focus).
-
AdaptiveBehavior (Sample) Observes bounds changes of a control (or a specified source) and conditionally adds or removes CSS-style classes based on adaptive rules.
-
AdaptiveClassSetter (Sample) Specifies comparison conditions (min/max width/height) and the class to apply when those conditions are met.
-
AspectRatioBehavior (Sample) Observes bounds changes and toggles CSS-style classes when the control's aspect ratio matches specified rules.
-
AspectRatioClassSetter (Sample) Defines aspect ratio comparison conditions and the class to apply when those conditions are met.
- HorizontalScrollViewerBehavior (No sample available.) Enables horizontal scrolling via the pointer wheel. Optionally requires the Shift key and supports line or page scrolling.
- ViewportBehavior (Sample) Tracks when the associated element enters or exits a ScrollViewer's viewport.
- ActiveScreenBehavior (No sample available.) Provides the currently active screen for a window.
- RequestScreenDetailsAction (Sample) Requests extended screen information using a Screens instance.
- ScreensChangedTrigger (No sample available.) Triggers actions when the available screens change.
- SelectingItemsControlEventsBehavior (No sample available.)
Handles selection-changed events in controls that support item selection (like ListBox) to trigger custom actions.
- SelectingItemsControlSearchBehavior (Sample)
Enables searching and highlights matching items within a SelectingItemsControl.
Sorting can be enabled with
EnableSorting
and configured using theSortOrder
property (ascending by default).
- SelectingItemsControlSearchBehavior (Sample)
Enables searching and highlights matching items within a SelectingItemsControl.
Sorting can be enabled with
-
ShowBehaviorBase (No sample available.) A base class for behaviors that “show” (make visible) a target control when a trigger condition is met.
-
ShowOnDoubleTappedBehavior (No sample available.) Shows a control when a double-tap gesture is detected.
-
ShowOnKeyDownBehavior (No sample available.) Shows a control when a specified key (or key gesture) is pressed.
-
ShowOnTappedBehavior (No sample available.) Shows the target control when it is tapped.
-
ButtonOpenFilePickerBehavior (Sample) Attaches to a Button to open a file picker dialog when clicked.
-
ButtonOpenFolderPickerBehavior (Sample) Attaches to a Button to open a folder picker dialog when clicked.
-
ButtonSaveFilePickerBehavior (Sample) Attaches to a Button to open a save file picker dialog when clicked.
-
StorageFileToReadStreamConverter (No sample available.) Converts an IStorageFile into a read stream (asynchronously).
-
StorageFileToWriteStreamConverter (No sample available.) Converts an IStorageFile into a write stream (asynchronously).
-
StorageItemToPathConverter (Sample) Extracts the file system path from an IStorageItem.
-
PickerActionBase (No sample available.) Base class for actions that invoke file/folder picker dialogs.
-
PickerBehaviorBase (No sample available.) Base class for behaviors that wrap file/folder picker functionality.
-
MenuItemOpenFilePickerBehavior (Sample) Opens a file picker dialog when a MenuItem is clicked.
-
MenuItemSaveFilePickerBehavior (Sample) Opens a save file picker dialog when a MenuItem is clicked.
-
MenuItemOpenFolderPickerBehavior (Sample) Opens a folder picker dialog when a MenuItem is clicked.
-
OpenFilePickerAction (Sample) Opens a file picker dialog and passes the selected file(s) as a command parameter.
-
OpenFilePickerBehaviorBase (No sample available.) Base behavior for opening file picker dialogs.
-
OpenFolderPickerAction (Sample) Opens a folder picker dialog and passes the selected folder(s) as a command parameter.
-
OpenFolderPickerBehaviorBase (No sample available.) Base behavior for opening folder picker dialogs.
-
SaveFilePickerAction (Sample) Opens a save file picker dialog and passes the chosen file as a command parameter.
-
SaveFilePickerBehaviorBase (No sample available.) Base behavior for saving files using a file picker dialog.
- ExecuteScriptAction (Sample) Executes a C# script using the Roslyn scripting API.
-
ClearNavigationStackAction (Sample) Resets the ReactiveUI navigation stack.
-
NavigateAction (Sample) Navigates to a specified
IRoutableViewModel
using a router. -
NavigateToAction (Sample) Resolves and navigates to a view model type using a router.
-
NavigateBackAction (Sample) Navigates back within a
RoutingState
stack. -
NavigateAndReset (Sample) Navigates to a view model and clears the navigation stack.
-
NavigateToAndResetAction (Sample) Resolves a view model type, clears the navigation stack, and navigates to it.
-
ObservableTriggerBehavior (Sample) Subscribes to an
IObservable
and executes actions whenever the observable emits a value.
-
AutoSelectBehavior (Sample) Selects all text in a TextBox when it is loaded.
-
TextBoxSelectAllOnGotFocusBehavior (No sample available.) Selects all text in a TextBox when it gains focus.
-
TextBoxSelectAllTextBehavior (No sample available.) Selects all text in a TextBox immediately upon attachment.
- TreeViewFilterBehavior (Sample) Filters tree view nodes based on a search box.
- TreeViewFilterTextChangedTrigger (Sample) Triggers actions when the search box text changes.
- ApplyTreeViewFilterAction (Sample) Filters the target TreeView using a provided query.
- ToggleIsExpandedOnDoubleTappedBehavior (Sample) Toggles the IsExpanded property of a TreeViewItem when it is double-tapped.
- SplitViewStateBehavior (Sample)
Automatically updates
DisplayMode
,PanePlacement
, andIsPaneOpen
based on size conditions. - SplitViewStateSetter (Sample) Specifies size conditions and target values used by SplitViewStateBehavior.
- SplitViewPaneOpeningTrigger (Sample) Triggers actions when the pane is about to open.
- SplitViewPaneOpenedTrigger (Sample) Triggers actions after the pane has opened.
- SplitViewPaneClosingTrigger (Sample) Triggers actions when the pane is about to close.
- SplitViewPaneClosedTrigger (Sample) Triggers actions after the pane has closed.
- ComboBoxValidationBehavior (Sample) Validates the selected item of a ComboBox.
- DatePickerValidationBehavior (Sample) Validates the selected date of a DatePicker.
- SliderValidationBehavior (Sample) Validates the value of a range-based control like Slider.
- NumericUpDownValidationBehavior (Sample) Validates the value of a NumericUpDown.
- TextBoxValidationBehavior (Sample) Validates the text value of a TextBox.
- PropertyValidationBehavior (No sample available.) Base behavior for validating an Avalonia property using rules.
- IValidationRule (No sample available.) Defines a method used to validate a value.
- RequiredTextValidationRule (Sample) Ensures text is not empty.
- RequiredDecimalValidationRule (Sample) Ensures a decimal value is provided.
- RequiredDateValidationRule (Sample) Ensures a date value is provided.
- MaxValueValidationRule (Sample) Checks that a numeric value does not exceed a maximum.
- MinValueValidationRule (Sample) Checks that a numeric value is not below a minimum.
- MinLengthValidationRule (No sample available.) Requires a string to have a minimum length.
- NotNullValidationRule (Sample) Ensures an object is not null.
- RangeValidationRule (Sample) Validates that a value is within a specified range.
- RegexValidationRule (Sample) Validates a string using a regular expression.
- DialogOpenedTrigger (Sample) Triggers actions when a window is opened.
- DialogClosedTrigger (Sample) Triggers actions when a window is closed.
- ShowDialogAction (Sample) Shows a window as a dialog.
- CloseWindowAction (Sample) Closes a window when executed.
-
Action (Sample) The base class for actions that can be executed by triggers.
-
Behavior (Sample) The base class for behaviors that attach to Avalonia objects.
-
Behavior (No sample available.) Generic base class for behaviors that require a specific type of associated object.
-
Trigger (Sample) A base class for triggers that execute a collection of actions when activated.
-
Trigger (No sample available.) Generic version of Trigger for strongly typed associated objects.
-
ActionCollection (Sample) A collection of actions that can be executed by a trigger.
-
BehaviorCollection (Sample) A collection of behaviors attached to a single Avalonia object.
-
ComparisonConditionType (No sample available.) Defines the types of comparisons (equal, not equal, less than, etc.) used in data and adaptive triggers.
-
IAction (No sample available.) Interface that defines the Execute method for custom actions.
-
IBehavior (No sample available.) Interface for behaviors that can attach and detach from an Avalonia object.
-
IBehaviorEventsHandler (No sample available.) Interface for handling events (loaded, attached, etc.) within behaviors.
-
ITrigger (No sample available.) Interface for triggers that encapsulate a collection of actions.
-
StyledElementAction (No sample available.) A base class for actions that work with StyledElement objects.
-
StyledElementBehavior (No sample available.) A base class for behaviors targeting StyledElement objects.
-
StyledElementBehavior (No sample available.) Generic base class for behaviors that are attached to a specific type of StyledElement.
-
StyledElementTrigger (No sample available.) A base trigger class for StyledElement objects.
-
StyledElementTrigger (No sample available.) Generic version of the StyledElementTrigger for typed associated objects.
- BehaviorCollectionTemplate (Sample) Defines a XAML template for creating a collection of behaviors.
- ObjectTemplate (Sample) A template for creating custom objects.
- Interaction (Sample) A static helper class for managing behavior collections and executing actions associated with triggers.
XAML Behaviors is licensed under the MIT license.