← ClaudeAtlas

using-wpf-behaviors-triggerslisted

Implements XAML behaviors and triggers using Microsoft.Xaml.Behaviors.Wpf. Use when adding interactivity to XAML without code-behind, implementing EventToCommand patterns, or creating reusable behaviors.
christian289/dotnet-with-claudecode · ★ 41 · Data & Documents · score 73
Install: claude install-skill christian289/dotnet-with-claudecode
# WPF Behaviors and Triggers ## 1. Setup ### 1.1 Install NuGet Package ```xml <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.*" /> ``` ### 1.2 XAML Namespace ```xml <Window xmlns:b="http://schemas.microsoft.com/xaml/behaviors"> ``` --- ## 2. EventTrigger Executes actions when events occur. ### 2.1 InvokeCommandAction (MVVM Recommended) ```xml <Button Content="Click Me"> <b:Interaction.Triggers> <b:EventTrigger EventName="Click"> <b:InvokeCommandAction Command="{Binding ClickCommand}"/> </b:EventTrigger> </b:Interaction.Triggers> </Button> ``` ### 2.2 With Event Args ```xml <ListBox> <b:Interaction.Triggers> <b:EventTrigger EventName="SelectionChanged"> <b:InvokeCommandAction Command="{Binding SelectionChangedCommand}" PassEventArgsToCommand="True"/> </b:EventTrigger> </b:Interaction.Triggers> </ListBox> ``` ### 2.3 ChangePropertyAction ```xml <Button Content="Toggle Visibility"> <b:Interaction.Triggers> <b:EventTrigger EventName="Click"> <b:ChangePropertyAction TargetName="MyPanel" PropertyName="Visibility" Value="Collapsed"/> </b:EventTrigger> </b:Interaction.Triggers> </Button> <StackPanel x:Name="MyPanel"/> ``` --- ## 3. DataTrigger Executes actions based on data conditions. ```xml <TextBlock Text="{Binding Status}">