Skip to content

XAML CommandParameter and enum values #407

Answered by michael-hawker
hawkerm asked this question in Q&A
Discussion options

You must be logged in to vote

I have confirmed this is indeed a platform bug with UWP/XAML. I wrote a simple MarkupExtension and it provided the value and passed it correctly. I've posted that solution in that thread here: microsoft/microsoft-ui-xaml#7633 (comment)

[MarkupExtensionReturnType(ReturnType = typeof(object))]
public class EnumValueExtension : MarkupExtension
{
    public Type Type { get; set; }

    public string Member { get; set; }

    protected override object ProvideValue()
    {
        return Enum.Parse(Type, Member);
    }
}
<RadioButton Command="{x:Bind ViewModel.SwitchPaneOrientationCommand, Mode=OneWay}"
             CommandParameter="{helper:EnumValue Type=model:PaneOrientation,

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@michael-hawker
Comment options

Answer selected by michael-hawker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants