using-wpf-behaviors-triggerslisted
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}">