【问题标题】:Bind Button.Command to another element by name按名称将 Button.Command 绑定到另一个元素
【发布时间】:2014-11-30 12:38:53
【问题描述】:

我有Button,名为left_buttonScrollViewer,名为scrollv。如何在没有代码隐藏的情况下将Button.Command 绑定到ScrollViewer.LineLeftCommand

【问题讨论】:

  • 是否要将Button.CommandScrollViewer.LineLeftCommand 绑定到同一个ICommand
  • ScrollViewer 有一些命令,我​​想通过按钮单击调用它,而不需要代码隐藏。可能是我做的不对,两年多没认真工作过WPF。
  • 我正在寻找ScrollViewer.LineLeftCommand,但没有找到。你的意思是ScrollBar.LineLeftCommand?你在找吗:<Button Command="ScrollViewer.LineLeftCommand" ... />
  • 哦,谢谢。与 CommandTarget={Binding ElementName=name} 一起使用,一切正常。

标签: wpf binding command action


【解决方案1】:

感谢哈姆雷特 Hakobyan。 绑定到滚动条:

<Button Command="ScrollBar.LineLeftCommand" CommandTarget="{Binding ElementName=PART_HorizontalScrollBar}"/>

【讨论】:

    猜你喜欢
    • 2013-11-05
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2018-10-21
    相关资源
    最近更新 更多