--- name: binding-enum-command-parameters description: "Binds enum values to WPF CommandParameter using x:Static markup extension. Use when passing enum types to commands or avoiding string-based command parameter errors." --- # WPF Command Parameter Enum Type Binding ## Problem Scenario When binding enum values to `CommandParameter` in WPF, **passing as string causes type mismatch error**. ### Error Message ``` System.ArgumentException: 'Parameter "parameter" (object) cannot be of type System.String, as the command type requires an argument of type MyNamespace.MyEnum.' ``` ### Cause 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. --- ## Solution ### Use `x:Static` to Directly Reference Enum Value ```xml xmlns:viewmodels="clr-namespace:MyApp.ViewModels;assembly=MyApp.ViewModels"