[英]Binding to other controlls InputBindings
我想绑定Keybindings
我的Button
的Keybindings
我的Window
。
我的窗口( Name="Mainwindow
)输入绑定:
<Window.InputBindings>
<KeyBinding Key="Return" Command="{Binding KeyPressed}" CommandParameter="Next"/>
</Window.InputBindings>
我对Button应该是什么样子的想法
<Button Content="Select Directory" Command="{Binding BrowseDirectory}">
<Button.InputBindings>
<KeyBinding Key="Return" Command="{Binding ElementName=Mainwindow, Path=InputBindings}"/>
</Button.InputBindings>
</Button>
令人遗憾的是,Outwindow没有显示任何其他Binderror任何其他任何东西,以告诉我为什么它不工作。
因此,问题是:如何将Control.InputBindings
绑定到另一个Control.InputBindings
?
为什么不将Command
属性绑定到同一个源属性:
<Button Content="Select Directory" Command="{Binding BrowseDirectory}">
<Button.InputBindings>
<KeyBinding Key="Return" Command="{Binding Path=DataContext.KeyPressed, RelativeSource={RelativeSource AncestorType=Window}}"/>
</Button.InputBindings>
</Button>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.