如何在WPF中为单个按钮编写Multile命令 [英] How to write Multile command for a single Button in WPF

查看:84
本文介绍了如何在WPF中为单个按钮编写Multile命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一种情况,我需要为同一按钮编写多个命令.有人可以帮我吗?

Hi
I have a scenario where i need to write multiple commands for the same button. Can anybody help me please?

<grid>
        <Button Content="Button" Height="23" HorizontalAlignment="Left" Command="{Binding ClickedCommand1}" Command="{Binding ClickedCommand2}" Margin="220,138,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    </grid>



我已经编写了上面的代码,并且它给我的错误命令已经存在.

谢谢
s. Keshaavan



I have written the above code and its giving me error command already exists.

Thanks
s. Keshaavan

推荐答案

您永远不需要多个命令".您只需要单击几个不同的方法,例如方法A,B和C.命令"实际上是一个委托实例.它应该是具有以下简单实现的某些命名或匿名委托实例:调用A,B和C.:-)

很简单,不是吗?

—SA
You never need "multiple commands". You just need several different methods called on a click, say, methods A, B and C. A "command" is actually a delegate instance. It should be some named or anonymous delegate instance with the following simple implementation: call A, B and C. :-)

Simple, isn''t it?

—SA


您需要MultiBinding

阅读这些页面:
http://www.switchonthecode.com/tutorials/wpf-tutorial-using-multibindings [ ^ ]

http://msdn.microsoft.com/en-us/library/system. windows.data.imultivalueconverter.aspx [ ^ ]

使用Google查找有关此主题的更多信息.

希望对您有所帮助.
You need MultiBinding

Read these pages :
http://www.switchonthecode.com/tutorials/wpf-tutorial-using-multibindings[^]

http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter.aspx[^]

use Google to find more info on this topic.

Hope it helps.


在第一次命中时使用标志加1,因此
Use a flag when first hit add 1 and so


这篇关于如何在WPF中为单个按钮编写Multile命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆