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 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.
First, clone the repository or download the latest zip.
git clone https://github.com/wieslawsoltes/AvaloniaBehaviors.git
git submodule update --init --recursive
- Visual Studio Community 2017 for
Windows
builds. - MonoDevelop for
Linux
builds.
Open AvaloniaBehaviors.sln
in selected IDE and run Build
command.
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 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
- Avalonia.Xaml.Interactivity - Core library.
- Avalonia.Xaml.Interactions - Default actions and behaviors.
- Avalonia.Xaml.Interactions.Custom - Custom actions and behaviors.
- Avalonia.Xaml.Behaviors - Meta package containing core library and default actions and behaviors
- Avalonia
- System.Reactive
- System.Reactive.Core
- System.Reactive.Interfaces
- System.Reactive.Linq
- System.Reactive.PlatformServices
- Serilog
- Splat
- Sprache
Avalonia XAML Behaviors is licensed under the MIT license.