这是我的问题,我想在按下这支画布时通过整数1。每次点击画布时,我都会在galasoft.mvvmlight.dll中出现一个未经处理的类型“ system.invalidcastexception”的例外。现在,我可以使自己的生活更轻松,只是做接力的命令以接受弦而不是int,而是为了学习。我将如何这样做,

    <i:Interaction.Triggers>
   <i:EventTrigger EventName="MouseLeftButtonDown">
         <cmd:EventToCommand Command="{Binding ButtonPress}"
                 CommandParameterValue="1"
              </i:EventTrigger>
    </i:Interaction.Triggers>
有帮助吗?

解决方案

其他提示

您可以使用以下语法将字符串以外的数据类型传递到命令:

<i:EventTrigger EventName="MouseLeftButtonDown">
    <cmd:EventToCommand Command="{Binding ButtonPress}">
        <cmd:EventToCommand.CommandParameterValue>
            <s:Int32>1</s:Int32>
        </cmd:EventToCommand.CommandParameterValue>
    </cmd:EventToCommand>
</i:EventTrigger>

添加s的流动名称空间声明:

xmlns:s="clr-namespace:System;assembly=mscorlib"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top