0

Working on a WPF / MVVM project. Still a noob at XAML. I do not manage to pass an enum parameter to a RelayCommand

public enum MyEnum {Val1, Val2, Val3};

xaml part:

<Button   Command="{Binding DataContext.MyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}">
   <Button.CommandParameter>
          <MultiBinding Converter="{StaticResource MultiValueConverter}">
                <!-- all my other parameters that wok fne-->
                <Binding  Path="{StaticResource MyEnum.Val1}"/>
          </MultiBinding>
    </Button.CommandParameter>
</Button>RelayCommand

which is declared as a resource this way:

  <vm:MyEnum x:Key="MyEnum " />

What id I miss?

A.D.
  • 1,062
  • 1
  • 13
  • 37
  • Have a look at this: http://stackoverflow.com/a/360076/869621 (not marking it as a duplicate because I don't know if multi-parameters commands work the same way, but I see no reason why not) – Kevin Gosse Jun 17 '16 at 08:20
  • 1
    What is "multi-parameters RelayCommand"? Could you post a declaration? – Dennis Jun 17 '16 at 08:37

1 Answers1

0

Either the blank at the end of your resourcekey is the problem or you could try the following:

{x:Static vm:MyEnum.Val1}"

EDIT:

To clarify this Snippet:

<Binding  Path="{x:Static vm:MyEnum.Val1}"/>

But if you are always binding the same value, you can also put that enumvalue as constant in your converter.

lokusking
  • 7,396
  • 13
  • 38
  • 57