Make Wpf Behavior
БесплатноБез исполняемых скриптовНе проверенGenerates WPF Behavior<T> classes using Microsoft.Xaml.Behaviors.Wpf. Use when adding reusable interaction logic to controls, creating drag behaviors, or…
от christian289★ 42 звезды на GitHubОб этом скилле
WPF Behavior Generator
If $0 is empty, use the AskUserQuestion tool to ask: "Enter the Behavior name (e.g., SelectAllOnFocus, DragMove)". Do NOT proceed until a valid name is provided. Use the response as the BehaviorName for all subsequent steps.
Generate a $0Behavior class based on Microsoft.Xaml.Behaviors.Wpf.
- Replace
{TargetType}with the appropriate WPF type (e.g., TextBox, UIElement, Window) based on the behavior name and context. - Replace
{Namespace}with the project's root namespace detected from csproj or existing code. - Replace
{Project}with the target project path.
Generated Code
namespace {Namespace}.Behaviors;
public sealed class $0Behavior : Behavior<{TargetType}>
{
#region Dependency Properties
public static readonly DependencyProperty IsEnabledProperty =
DependencyProperty.Register(
nameof(IsEnabled),
typeof(bool),
typeof($0Behavior),
new PropertyMetadata(true));
public bool IsEnabled
{
get => (bool)GetValue(IsEnabledProperty);
set => SetValue(IsEnabledProperty, value);
}
#endregion
#region Lifecycle
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Loaded += OnLoaded;
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.Loaded -= OnLoaded;
}
#endregion
#region Event Handlers
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (!IsEnabled)
{
return;
}
// TODO: Implement behavior logic
}
#endregion
}
XAML Usage
<Window xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:behaviors="clr-namespace:{Namespace}.Behaviors">
<{TargetType}>
<b:Interaction.Behaviors>
<behaviors:$0Behavior IsEnabled="{Binding IsBehaviorEnabled}"/>
</b:Interaction.Behaviors>
</{TargetType}>
</Window>
Common Behavior Patterns
Focus Management
public sealed class FocusOnLoadBehavior : Behavior<UIElement>
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.Loaded += (s, e) => AssociatedObject.Focus();
}
}
Input Handling
public sealed class EnterKeyBehavior : Behavior<TextBox>
{
public static readonly DependencyProperty CommandProperty =
DependencyProperty.Register(nameof(Command), typeof(ICommand),
typeof(EnterKeyBehavior));
public ICommand? Command
{
get => (ICommand?)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.KeyDown += OnKeyDown;
}
protected override void OnDetaching()
{
base.OnDetaching();
AssociatedObject.KeyDown -= OnKeyDown;
}
private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
Command?.Execute(AssociatedObject.Text);
}
}
}
Required Package
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.*" />
File Location
{Project}/
└── Behaviors/
└── $0Behavior.cs
Best Practices
| DO | DON'T |
|---|---|
| Unsubscribe events in OnDetaching | Missing event unsubscription (memory leak) |
| Expose settings via DependencyProperty | Use hardcoded values |
| Apply IsEnabled pattern | Always execute without condition |
| Check AssociatedObject for null | Use without null check |
Related
/wpf-dev-pack:make-wpf-chatclientemits two workedBehavior<T>instances built on this template: anEnterCommandBehavior(Enter=send / Shift+Enter=newline, IME-safe, viaPreviewKeyDownwith aCommand/CommandParameterDP pair) and aStickToBottomBehavior(pin a streamingScrollViewerto the newest content unless the user scrolled up). See it for a Command-DP behavior and an event-tracking behavior in context.
Установить Make Wpf Behavior в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Make Wpf Behavior?
Generates WPF Behavior<T> classes using Microsoft.Xaml.Behaviors.Wpf. Use when adding reusable interaction logic to controls, creating drag behaviors, or scaffolding a new Behavior class. Usage: /wpf-dev-pack:make-wpf-behavior <BehaviorName>
Как установить скилл Make Wpf Behavior?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Make Wpf Behavior запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic