Help us improve
Share bugs, ideas, or general feedback.
From wpf-dev-pack
Resolves WPF CommandParameter enum type mismatch errors using x:Static markup extension to pass actual enum values instead of strings in MVVM commands.
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packHow this skill is triggered — by the user, by Claude, or both
Slash command
/wpf-dev-pack:binding-enum-command-parametershaikuThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> **MVVM Framework Rule**: `.claude/rules/dotnet/wpf/mvvm-framework.md` 설정에 따라 코드 스타일이 결정됩니다.
Implements WPF input handling patterns using RoutedCommand, ICommand, CommandBinding, and InputBinding for keyboard shortcuts, menu commands, and custom implementations.
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Share bugs, ideas, or general feedback.
MVVM Framework Rule:
.claude/rules/dotnet/wpf/mvvm-framework.md설정에 따라 코드 스타일이 결정됩니다. Prism 9 사용 시 → PRISM.md 참조
When binding enum values to CommandParameter in WPF, passing as string causes type mismatch error.
System.ArgumentException: 'Parameter "parameter" (object) cannot be of type System.String,
as the command type requires an argument of type MyNamespace.MyEnum.'
When specifying CommandParameter="Pan" as a string in XAML, WPF passes it as System.String type. However, if the Command expects a specific enum type, automatic type conversion does not occur.
x:Static to Directly Reference Enum Value<!-- Namespace declaration -->
xmlns:viewmodels="clr-namespace:MyApp.ViewModels;assembly=MyApp.ViewModels"
<!-- Wrong method (passed as String) -->
<Button Command="{Binding SelectToolCommand}"
CommandParameter="Pan" />
<!-- Correct method (passed as Enum type) -->
<Button Command="{Binding SelectToolCommand}"
CommandParameter="{x:Static viewmodels:ViewerTool.Pan}" />
public enum ViewerTool
{
None,
Pan,
Zoom,
WindowLevel
}
public partial class ViewerViewModel : ObservableObject
{
[ObservableProperty] private ViewerTool _currentTool = ViewerTool.Pan;
[RelayCommand]
private void SelectTool(ViewerTool tool)
{
CurrentTool = tool;
}
}
<UserControl xmlns:viewmodels="clr-namespace:MyApp.ViewModels;assembly=MyApp.ViewModels">
<StackPanel Orientation="Horizontal">
<!-- Select Pan tool -->
<ToggleButton Content="Pan"
Command="{Binding SelectToolCommand}"
CommandParameter="{x:Static viewmodels:ViewerTool.Pan}"
IsChecked="{Binding CurrentTool,
Converter={StaticResource EnumToBoolConverter},
ConverterParameter={x:Static viewmodels:ViewerTool.Pan}}" />
<!-- Select Zoom tool -->
<ToggleButton Content="Zoom"
Command="{Binding SelectToolCommand}"
CommandParameter="{x:Static viewmodels:ViewerTool.Zoom}"
IsChecked="{Binding CurrentTool,
Converter={StaticResource EnumToBoolConverter},
ConverterParameter={x:Static viewmodels:ViewerTool.Zoom}}" />
<!-- Select Window/Level tool -->
<ToggleButton Content="W/L"
Command="{Binding SelectToolCommand}"
CommandParameter="{x:Static viewmodels:ViewerTool.WindowLevel}"
IsChecked="{Binding CurrentTool,
Converter={StaticResource EnumToBoolConverter},
ConverterParameter={x:Static viewmodels:ViewerTool.WindowLevel}}" />
</StackPanel>
</UserControl>
assembly= when using enum from different projectx:Static for ConverterParameter as wellpublic class EnumToBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value?.Equals(parameter) ?? false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? parameter : Binding.DoNothing;
}
}