我不介意制作按钮单击方法,但命令 *** 作长时间运行,执行时间将取决于ExecuteParameter的值(在这种情况下是表示机器物理位置的双元组).
XAML:
<button FontFamily="Marlett" FontSize="40" Content="5" HorizontalAlignment="Center" VerticalAlignment="top" margin="100" WIDth="100" Height="50" Command="{Binding IncrBAnglePos}" CommandParameter="{Binding Elementname=slIDer,Path=Value}"></button>
C#:
SystemCommands.AddSubSystemCommand(SystemRef,Commandnames.IncrAngle,new RelayCommand( o => { double AngleIncr = (double)o > 5 ? 5 : (double)o; double nextX = MotionControl.liveX; double nextB = MotionControl.liveB + AngleIncr; nextB = nextB >= 45 ? 45 : nextB; Task.Run(() => { SystemCommands.ExecuteCommand(Commandnames.Gotoposition,new Tuple<double,double>(nextX,nextB)); }); },_ => { if (MotionControl == null) return false; return !MotionControl.InMotionCheckStatus; }));if (MotionControl != null){ MotionControl.MotionChanged += SystemCommands.GetRelayCommand(Commandnames.IncrAngle).CanExecutePropertyChangednotification;}
更新:我可以看到一些人在看了一眼就戳了戳头.如果有人对我如何改进问题提出建议,我会欢迎反馈意见.由于我缺乏声誉,你可能会猜测我是新手.
解决方法 Repeat Button应该做你想要的Interval – >重复开始后重复之间的时间量(以毫秒为单位).该值必须是非负的.
Delay – >在重复开始重复之前,Repeatbutton在按下时等待的时间量(以毫秒为单位).
<Repeatbutton FontFamily="Marlett" Delay="500" Interval="100" FontSize="40" Content="5" HorizontalAlignment="Center" VerticalAlignment="top" margin="100" WIDth="100" Height="50" Command="{Binding IncrBAnglePos}" CommandParameter="{Binding Elementname=slIDer,Path=Value}"></Repeatbutton>总结
以上是内存溢出为你收集整理的c# – 按住按钮重复命令全部内容,希望文章能够帮你解决c# – 按住按钮重复命令所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)