Skip to content

microsoft/XamlBehaviors

Folders and files

NameName
Last commit message
Last commit date
Dec 3, 2024
Oct 17, 2017
Nov 19, 2015
Dec 3, 2024
Feb 24, 2020
Nov 22, 2024
Dec 2, 2024
Dec 3, 2024
Jul 23, 2015
Sep 9, 2015
Sep 10, 2024
Nov 22, 2024
Jul 20, 2015
Dec 3, 2024
Sep 26, 2022

Repository files navigation

XAML Behaviors

XAML Behaviors is an easy-to-use means of adding common and reusable interactivity to your Windows UWP applications with minimal code. It is available for managed applications only. Use of XAML Behaviors is governed by the MIT License

Build Status

Platform Status
Managed Build Managed

Getting Started

Where to get it

Resources

More Info

Code Example

For an example of using Behaviors in an application, here is a snippet of XAML:

<Button xmlns:Interactivity="using:Microsoft.Xaml.Interactivity">
    <Interactivity:Interaction.Behaviors>
        <Interactivity:EventTriggerBehavior EventName="Click">
            <Interactivity:ChangePropertyAction PropertyName="Background">
                <Interactivity:ChangePropertyAction.Value>
                    <SolidColorBrush Color="Red"/>
                </Interactivity:ChangePropertyAction.Value>
            </Interactivity:ChangePropertyAction>
        </Interactivity:EventTriggerBehavior>
    </Interactivity:Interaction.Behaviors>
</Button>

Using Behaviors SDK

The documentation explains how to install Visual Studio, add the XAML Behaviors NuGet package to your project, and get started using the API.

Building Behaviors from Source

What You Need

Clone the Repository

Build and Create Managed XAML Behaviors NuGet

  • Ensure that nuget.exe is available in PATH
  • If you're using Visual Studio
    • Open the "BehaviorsSDKManaged.sln" solution in Visual Studio
    • Change Build Configuration to Release
    • Build solution with right click > Build, or by clicking F6
  • If you're building from CLI (Visual Studio Developer Command prompt):
    • Run nuget restore src\BehaviorsSDKManaged\BehaviorsSDKManaged.sln
    • Run msbuild -t:build src\BehaviorsSDKManaged\BehaviorsSDKManaged.sln /p:Configuration=Release

For UWP:

  • Run msbuild /t:pack src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity.Uwp\Microsoft.Xaml.Interactivity.Uwp.csproj /p:Configuration=Release
    • (Optional) Add /p:TimestampPackage=true to include the timestamp in the NuGet package version

For WinUI:

  • Run msbuild /t:Pack src\BehaviorsSDKManaged\Microsoft.Xaml.Interactivity.WinUI\Microsoft.Xaml.Interactivity.WinUI.csproj /p:Configuration=Release
    • (Optional) Add /p:TimestampPackage=true to include the timestamp in the NuGet package version