我在VM中有这个代码:
public void MovePixels(int NoOfPixelsToMove)
{
// do something with NoOfPixelsToMove
}
在我的xaml上我有:
<RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(100)]" Content="<<<" Margin="3" ClickMode="Press" />
<RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(10)]" Content="<<" Margin="3" ClickMode="Press"/>
<RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(1)]" Content="<" Margin="3" ClickMode="Press"/>
<RepeatButton DockPanel.Dock="Right" cal:Message.Attach="[Event Click]=[MovePixels(-100)]" Content=">>>" Margin="3" ClickMode="Press"/>
<RepeatButton DockPanel.Dock="Right" cal:Message.Attach="[Event Click]=[MovePixels(-10)]" Content=">>" Margin="3" ClickMode="Press"/>
<RepeatButton DockPanel.Dock="Right" cal:Message.Attach="[Event Click]=[MovePixels(-1)]" Content=">" Margin="3" ClickMode="Press"/>
当我点击应该传递100到vm方法的按钮时,我在vm方法上得到100的值,但是当我点击NoOfPixelsToMove为负的任何按钮时,传递给VM方法的值为零
为什么我不能使用caliburn micro向VM传递小于零的值?
答案 0 :(得分:1)
我认为表达式没有正确解析它。尝试在数字前添加'-'
'
。