0
UI 트리 위로 생성 된 명령을 컨트롤에 바인딩하는 데 문제가 있습니다. 다음 예는 내 요점을 설명하고 Grid
에있는 CommandBinding
은 Window의 InputBindings
에서 작동하지 않습니다. 어쩌면 내가 명령의 요점을 이해하지 못 하겠지만, 자식 컨트롤이 Window (Window의 모든 컨트롤)에서 사용자 입력에 대해 작동하는 좋은 솔루션을 갖고 싶습니다.Howto는 자식의 RoutedCommand를 바인딩합니까?
<Window x:Class="SilverFit.Menu.Wpf.WpfWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Window.InputBindings>
<KeyBinding Command="Close" Key="Escape"/>
<MouseBinding Command="Close" MouseAction="RightClick" />
</Window.InputBindings>
<Grid Name="grid">
<Grid.CommandBindings>
<CommandBinding Command="Close" Executed="Close"/>
</Grid.CommandBindings>
</Grid>
</Window>
바인딩은 Window 클래스에서 Close 메서드를 실행하므로 명령 대상은이 예제의 Window입니다. – Wouter
그러면 격자에있는 명령 바인딩은 그리드 안의 항목 *을 대상으로하는 명령 만 볼 수 있으며 라우트 된 이벤트 모델 때문에 자식의 라우팅 된 명령을 바인딩하는 것이 실제로 이해가되지 않는다는 대답이 있습니다. –