Skip to content

Binding Enum as CommandParameter does not preserve type #7633

@jeffmccormick

Description

@jeffmccormick

Describe the bug

Enumeration values passed as command parameters get bound as Int32s rather than their enumeration type. Below is a basic example:

XAML

<Button Command={x:Bind VM.MyCommand}>
    <Button.CommandParameter>
        <local:MyEnum>SomeValue<\local:MyEnum>
    <\Button.CommandParameter>
</Button>

ViewModel

private void DoMyCommand(object parameter)
{
    parameter.GetType() // System.Int32
}

Steps to reproduce the bug

Minimal repro using template:

EnumBinding.zip

Expected behavior

Parameter gets bound as the Enumeration type.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.1.4

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (21H2): Build 19044

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions