5

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

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
}
4

1 回答 1

14

您只需要将Enum 值作为 astring传递:

<MenuItem Header="Arrow" cal:Message.Attach="ChangeArrowType('ARROW')"/>
于 2012-10-21T06:24:42.930 回答