728x90
반응형
1. 위아래 Mouse Wheel Event
특별한 설정이 필요 없이 기본적으로 ScrollViewer를 사용하면 됩니다.
xaml 코드 |
<ScrollViewer VerticalScrollBarVisibility="Hidden"> <StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="1"/> <Button Content="2"/> <Button Content="3"/> <Button Content="4"/> <Button Content="5"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="6"/> <Button Content="7"/> <Button Content="8"/> <Button Content="9"/> <Button Content="10"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="11"/> <Button Content="12"/> <Button Content="13"/> <Button Content="14"/> <Button Content="15"/> </StackPanel> </StackPanel> </ScrollViewer> |
2. 좌우 Mouse Wheel Event
좌우 Mouse Wheel Event를 하기 위해서는 HorizontalScrollBarVisibility와 PreviewMouseWheel 이벤트를 설정해 주어야 합니다.
xaml 코드 |
<ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"> <StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="1"/> <Button Content="2"/> <Button Content="3"/> <Button Content="4"/> <Button Content="5"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="6"/> <Button Content="7"/> <Button Content="8"/> <Button Content="9"/> <Button Content="10"/> </StackPanel> <StackPanel Orientation="Horizontal"> <Button Content="11"/> <Button Content="12"/> <Button Content="13"/> <Button Content="14"/> <Button Content="15"/> </StackPanel> </StackPanel> </ScrollViewer> |
cs 코드 |
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { ScrollViewer sv = sender as ScrollViewer; if (0 > e.Delta) { sv.LineRight(); }else{ sv.LineLeft(); } e.Handled = true; } |
반응형
'프로그램 개발 > C#' 카테고리의 다른 글
[wpf] c# 코드로 Image Source 설정 (0) | 2020.12.13 |
---|---|
[wpf] Page에서 자식 Window 창 위치 가운데 설정 (0) | 2020.12.12 |
[wpf] xaml의 부등호 및 특수문자 정리 (0) | 2020.12.06 |
[wpf] Page에서 Window 닫기 (0) | 2020.12.05 |
[wpf] MariaDB 사용하기 - 2. c#에 연동하기(Microsoft Visual Studio) (0) | 2020.11.25 |