2017-11-06 13 views
1

cal:Message.Attach을 사용하여 ViewModel에서 함수를 실행하는 표준 WPF 단추가 있습니다. F2 버튼을 눌러도 동일한 기능을 실행하고 싶습니다.키 누르기 단추 동작

이것을 활성화 할 수있는 Caliburn Micro 바인딩을 사용하는 간단한 xaml 선언이 있습니까?

public MainWindow() 
{ 
    InitializeComponent(); 
    this.PreviewKeyDown += new KeyEventHandler(MainWindow_PreviewKeyDown); 
} 

void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e) 
{ 
    if ((e.Key == Key.F2)) 
    { 
     //DO SOMETHING 
    } 
} 

답변

3

오버라이드 Configure() 당신의 부트 스트 래퍼 방법 :

<Button x:Name="TheFunction" 
     Content="Click" 
     cal:Message.Attach="[Key F2] = [TheFunction];" /> 

이 있습니다 : https://github.com/Caliburn-Micro/Caliburn.Micro/blob/master/samples/scenarios/Scenario.KeyBinding/Bootstrapper.cs

... 그리고이 시도

+0

내 측면의 질문으로, ''를 사용할 때 우연히 발견했습니다. - 버튼이 없을 때 호출되는 함수를 가져옵니다. 집중 해? –