将一个枚举作为参数在caliburn micro的动作中传递

时间:2012-10-17 12:14:25

标签: c# .net wpf caliburn.micro

如何在消息操作中传入枚举?例如,

XAML:

<UserControl.ContextMenu>
    <ContextMenu StaysOpen="True">
        <MenuItem Header="Arrow"
                  cal:Message.Attach="ChangeArrowType(LogicArrowEnum.ARROW)"/>
     ....

视图模型:

public void ChangeArrowType(LogicArrowEnum arrowType)
{
    MessageBox.Show(arrowType); //arrowType is empty!

}

public enum LogicArrowEnum
{
    ARROW = 1,
    ASSIGN = 2,
    IF = 3,
    IF_ELSE = 4
}

1 个答案:

答案 0 :(得分:14)

您只需要传递Enum value as a string

<MenuItem Header="Arrow" cal:Message.Attach="ChangeArrowType('ARROW')"/>