728x90
반응형
WPF & C# - Scrollviewer PanningMode Touch Drag Scroll ( Both / HorizontalFirst / HorizontalOnly / None / VerticalFirst / VerticalOnly / 터치 드래그 / 스크롤 / 스크롤바 / Scrollbar / 상하좌우 / 가로세로 ) |
MainWindow.xaml.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <StackPanel VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10"> <Button x:Name="btn" Content="ScrollViewer PanningMode" Height="80" Click="btn_Click" FontWeight="Bold" FontSize="20"/> <ScrollViewer x:Name="sv" Height="250" Width="300" Background="#FFDABEBE" PanningMode="Both" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"> <StackPanel Height="400" Width="400"> <Ellipse Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Ellipse> <Rectangle Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Rectangle> <Ellipse Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Ellipse> <Rectangle Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Rectangle> <Ellipse Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Ellipse> <Rectangle Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Rectangle> <Ellipse Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Ellipse> <Rectangle Width="50" Height="50" Fill="#FFFFF489" Stroke="#FF5B5B5B"></Rectangle> </StackPanel> </ScrollViewer> </StackPanel> | cs |
MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int i = 0; int itemcount = 6; private void btn_Click(object sender, RoutedEventArgs e) { i++; if (i % itemcount == 0) sv.PanningMode = PanningMode.Both; if (i % itemcount == 1) sv.PanningMode = PanningMode.HorizontalFirst; if (i % itemcount == 2) sv.PanningMode = PanningMode.HorizontalOnly; if (i % itemcount == 3) sv.PanningMode = PanningMode.None; if (i % itemcount == 4) sv.PanningMode = PanningMode.VerticalFirst; if (i % itemcount == 5) sv.PanningMode = PanningMode.VerticalOnly; btn.Content= (i % itemcount).ToString() + " : " + sv.PanningMode; } | cs |
PanningMode
PanningMode 는 터치디바이스에서의 터치지원 모드이다.
PanningMode.Both
- 상하좌우 전체 스크롤 가능
PanningMode.HorizontalFirst
- 좌우로 움직인 후 상하좌우 전체 스크롤 가능
PanningMode.HorizontalOnly
- 좌우만 스크롤 가능
PanningMode.None (Default Value)
- 움직이지 않음 (디폴트 값)
PanningMode.VerticalFirst
- 상하로 움직인 후 상하좌우 전체 스크롤 가능
PanningMode.VerticalOnly
- 상하로만 스크롤 가능
728x90
반응형