Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

AvaloniaUI/Avalonia.Xaml.Behaviors

Repository files navigation

Avalonia XAML Behaviors

Gitter

Build status

NuGet MyGet

AvaloniaBehaviors 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.

Example Usage

Example of using Behaviors in an Avalonia XAML application:

<Window xmlns="https://github.com/avaloniaui"
        xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
        xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
        Width="500" Height="400">
    <Grid RowDefinitions="Auto,100">
        <TextBox Name="textBox" Text="Hello" Grid.Row="0" Margin="5"/>
        <Button Name="changePropertyButton" Content="Change Property" Grid.Row="1" Margin="5,0,5,5">
            <i:Interaction.Behaviors>
                <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #changePropertyButton}">
                    <ia:ChangePropertyAction TargetObject="{Binding #textBox}" PropertyName="Text" Value="World"/>
                </ia:EventTriggerBehavior>
            </i:Interaction.Behaviors>
        </Button>
    </Grid>
</Window>

More examples can be found in sample application.

Building Avalonia XAML Behaviors

First, clone the repository or download the latest zip.

git clone https://github.com/wieslawsoltes/AvaloniaBehaviors.git
git submodule update --init --recursive

Build using IDE

Open AvaloniaBehaviors.sln in selected IDE and run Build command.

Build on Windows using script

Open up a command-prompt and execute the commands:

.\build.ps1

Build on Linux using script

Open up a terminal prompt and execute the commands:

./build.sh

Build on OSX using script

Open up a terminal prompt and execute the commands:

./build.sh

NuGet

Avalonia XamlBehaviors is delivered as a NuGet package.

You can find the packages here NuGet and install the package like this:

Install-Package Avalonia.Xaml.Behaviors

or by using nightly build feed:

  • Add https://www.myget.org/F/xamlbehaviors-nightly/api/v2 to your package sources
  • Update your package using XamlBehaviors feed

and install the package like this:

Install-Package Avalonia.Xaml.Behaviors -Pre

NuGet Packages

Package Dependencies

Package Sources

Resources

License

Avalonia XAML Behaviors is licensed under the MIT license.