为什么负数不会传递给在caliburn micro中的ViewModel

时间:2014-04-15 15:08:43

标签: c# wpf caliburn.micro

我在VM中有这个代码:

 public void MovePixels(int NoOfPixelsToMove)
 {
            // do something with   NoOfPixelsToMove
 }

在我的xaml上我有:

 <RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(100)]" Content="&lt;&lt;&lt;" Margin="3" ClickMode="Press" />
 <RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(10)]" Content="&lt;&lt;" Margin="3" ClickMode="Press"/>
 <RepeatButton DockPanel.Dock="left" cal:Message.Attach="[Event Click]=[MovePixels(1)]" Content="&lt;" 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传递小于零的值?

1 个答案:

答案 0 :(得分:1)

我认为表达式没有正确解析它。尝试在数字前添加'-' '