2017-06-01 8 views
1

Keybindings私のButtonKeybindings私のWindowのバインドしたいと思います。他のコントロールにバインドするInputBindings

私の窓(Name="Mainwindow)入力結合:ボタンは悲しいことOutwindowが他の任意のものを与えることをBinderrorのいずれかの種類が表示されませんでした

<Button Content="Select Directory" Command="{Binding BrowseDirectory}"> 
    <Button.InputBindings> 
      <KeyBinding Key="Return" Command="{Binding ElementName=Mainwindow, Path=InputBindings}"/> 
     </Button.InputBindings> 
</Button> 

どのように見えるかの

<Window.InputBindings> 
    <KeyBinding Key="Return" Command="{Binding KeyPressed}" CommandParameter="Next"/> 
</Window.InputBindings> 

私の考え私はなぜそれが動作していないかの手掛かりです。
質問:私はControl.InputBindingsを別のControl.InputBindingsにどのようにバインドできますか?

あなただけの同じソースプロパティに Commandプロパティをバインドしていないのはなぜ
+0

あなたは、ウィンドウの上にキーバインドを持っている場合は、正しいキーが押されたとき、コマンドは、その上の複製、トリガされますボタンは時間の無駄になります – MikeT

+0

ボタンがフォーカスされると、戻りボタンはボタンをクリックします。クリックイベント - >コマンドの実行を開始します。 私はこれを克服する方法を探しています。今はの内容をに貼り付けることにしました。あまりにも美味しくはありませんが、私はプロッパーソリューションを探す時間を見つけるまで仕事をしています。 –

答えて

0

<Button Content="Select Directory" Command="{Binding BrowseDirectory}"> 
    <Button.InputBindings> 
     <KeyBinding Key="Return" Command="{Binding Path=DataContext.KeyPressed, RelativeSource={RelativeSource AncestorType=Window}}"/> 
    </Button.InputBindings> 
</Button> 
関連する問題