wpf 응용 프로그램에 익숙하며 응용 프로그램에서 작업 중이며 메뉴를 만들었습니다. 이제는 단축키 Ctrl + O, Ctrl + N 등에서 메뉴 항목 이벤트 기능을 원합니다. 어떻게 할 수 있습니까? 나는 그것을한다. 세부 사항을 나에게 줘라.Wpf 응용 프로그램에서 단축키 구현
3
A
답변
3
할 수 있습니다 그래서 다음과 같은 방법으로 .... 파일 뒤에 코드에서 XAML 파일
<Window x:Class="FocusDemo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FocusDemo"
Title="Window1" Height="300" Width="300">
<Window.CommandBindings>
<CommandBinding
Command=
"{x:Static
local:Window1.CustomRoutedCommand}"
Executed="ExecutedCustomCommand"
CanExecute="CanExecuteCustomCommand" >
</CommandBinding>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding
Command=
"{x:Static
local:Window1.CustomRoutedCommand}"
Key="S"
Modifiers="Control"/>
</Window.InputBindings>
<Grid>
<!--Your Controls-->
</Grid>
</Window>
에서
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public static RoutedCommand CustomRoutedCommand = new RoutedCommand();
public Window1()
{
InitializeComponent();
}
#region
public void ExecutedCustomCommand(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Ctrl+S");
}
public void CanExecuteCustomCommand(object sender,
CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
#endregion
}
출처 : Click here
하세요 대답이 정확하면 잊지 마라.
0
질문에 대한 정확한 대답은 아니지만 아마도 나 같은 사람은 Alt + O, Alt + N과 같은 메뉴 항목 (명령 단추)에 키보드 바로 가기를 추가하는 방법을 찾고있을 것입니다. 이 경우 항목 이름에 바로 가기 문자 앞에 구분 기호 (_)를 넣을 수 있습니다.
관련 문제
- 1. 내 응용 프로그램에서 단축키
- 2. 웹 응용 프로그램에서 사용 가능한 키보드 단축키
- 3. Gmail과 같은 단축키 구현 방법
- 4. 응용 프로그램에서 여러 화면 구현
- 5. 웹 응용 프로그램에서 MVP 구현
- 6. 안드로이드 응용 프로그램에서 소리 구현
- 7. Java 응용 프로그램에서 Growl 구현
- 8. 안드로이드 응용 프로그램에서 Google지도의 구현
- 9. 웹 응용 프로그램에서 검색 구현
- 10. C++ 응용 프로그램에서 스크립트 구현
- 11. wpf/win32 응용 프로그램을 혼합하여 응용 프로그램 전체 단축키 정의
- 12. WPF - WPF 응용 프로그램에서 xbap으로 전환
- 13. wpf 응용 프로그램에서 표 제공
- 14. WPF 응용 프로그램에서 GDI + 사용
- 15. WPF 응용 프로그램에서 silverlight 디버깅
- 16. WPF 응용 프로그램에서 PIX 사용
- 17. WPF 응용 프로그램에서 GraphViz 사용
- 18. wpf 응용 프로그램에서 busyindicator를 표시합니다.
- 19. WPF 응용 프로그램에서 파일 업로드
- 20. WPF 응용 프로그램에서 WinForm 시작
- 21. WPF 응용 프로그램에서 SendKeys.Send 메서드
- 22. WPF 응용 프로그램에서 상태 저장
- 23. WPF 응용 프로그램에서 WIA 스캔
- 24. 설정 응용 프로그램 전체 단축키
- 25. 웹 응용 프로그램의 단축키
- 26. 리눅스 C 응용 프로그램에서 사용자 정의 키보드 단축키 만들기
- 27. iPhone 응용 프로그램에서 데이터 암호화 구현
- 28. 응용 프로그램에서 만료 날짜를 구현 하시겠습니까?
- 29. 메트로 응용 프로그램에서 로거 클래스 구현
- 30. 다중 활동 응용 프로그램에서 WakefulIntentService 구현
http://blogs.windowsclient.net/vsdev/archive/2009/03/30/wpf-menu-how-to-implement-shortcut-keys.aspx – Kendrick
@Anu 어떤 프레임 워크에서 작업하고 있습니까? 닷넷 4.0 또는 닷넷 3.5 ?? – Ankesh
VS2010에서 작업 중입니다 .4.0 – Anu