/AvaloniaBehaviors

Port of Windows UWP Xaml Behaviors for Avalonia Xaml.

Primary LanguageC#MIT LicenseMIT

Avalonia XAML Behaviors

Gitter

Build status Build Status CircleCI

NuGet MyGet

CodeFactor

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 Powershell prompt and execute the bootstrapper script:

PS> .\build.ps1 -Target "Default" -Platform "Any CPU" -Configuration "Release"

Build on Linux/OSX using script

Open up a terminal prompt and execute the bootstrapper script:

$ ./build.sh --target "Default" --platform "Any CPU" --configuration "Release"

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.