-
Notifications
You must be signed in to change notification settings - Fork 140
Home
Fons Sonnemans edited this page Dec 6, 2018
·
8 revisions
XAML Behaviors for WPF is an easy-to-use means of adding common and reusable interactivity to your WPF applications with minimal code. Use of XAML Behaviors for WPF is governed by the MIT License
Where to get it
- NuGet package Microsoft.Xaml.Behaviors.Wpf
- Source Code
Resources
More Info
For an example of using Behaviors in an application, here is a snippet of XAML:
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
Title="MainWindow"
Height="450"
Width="800">
<Grid>
<behaviors:Interaction.Behaviors>
<behaviors:FluidMoveBehavior AppliesTo="Children" />
</behaviors:Interaction.Behaviors>
<Rectangle Fill="Blue"
Width="100"
Height="100">
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="MouseLeftButtonDown">
<behaviors:ChangePropertyAction PropertyName="Fill">
<behaviors:ChangePropertyAction.Value>
<SolidColorBrush Color="Red" />
</behaviors:ChangePropertyAction.Value>
</behaviors:ChangePropertyAction>
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</Rectangle>
</Grid>
</Window>
The documentation explains how to install Visual Studio, add the XAML Behaviors NuGet package to your project, and get started using the API.
What You Need
- Visual Studio 2019 preview 1 w/ Update 1
Clone the Repository
- Go to 'View' -> 'Team Explorer' -> 'Local Git Repositories' -> 'Clone'
- Add the XAML Behaviors repository URL (https://github.com/Microsoft/XamlBehaviorsWpf) and hit 'Clone'
Build and Create Managed XAML Behaviors NuGet
- Open a Visual Studio developer command prompt
- Navigate to the Xaml Behaviors for Wpf repository
- Run msbuild src\Microsoft.Xaml.Behaviors\Microsoft.Xaml.Behaviors.csproj /t:Pack
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Introduction
- Contribution
- Behaviors Reference
- CallMethodAction
- ChangePropertyAction
- ConditionBehavior
- ControlStoryboardAction
- DataStateBehavior
- FluidMoveBehavior
- FluidMoveSetTagBehavior
- GoToStateAction
- InvokeCommandAction
- LaunchUriOrFileAction
- MouseDragElementBehavior
- PlaySoundAction
- RemoveElementAction
- SetDataStoreValueAction
- TranslateZoomRotateBehavior