ScrollViewerPage.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:pages="using:ControlCatalog.Pages"
  4. x:Class="ControlCatalog.Pages.ScrollViewerPage"
  5. x:DataType="pages:ScrollViewerPageViewModel">
  6. <TabControl>
  7. <TabItem Header="ScrollViewer">
  8. <StackPanel Orientation="Vertical"
  9. Spacing="20">
  10. <TextBlock TextWrapping="Wrap"
  11. Classes="h2">Allows for horizontal and vertical content scrolling. Supports snapping on touch and pointer wheel scrolling.</TextBlock>
  12. <Grid ColumnDefinitions="Auto, *">
  13. <StackPanel Orientation="Vertical"
  14. Spacing="4">
  15. <ToggleSwitch IsChecked="{Binding AllowAutoHide}"
  16. Content="Allow auto hide" />
  17. <ToggleSwitch IsChecked="{Binding EnableInertia}"
  18. Content="Enable Inertia" />
  19. <ToggleSwitch IsChecked="{Binding #ScrollViewer.IsDeferredScrollingEnabled}"
  20. ToolTip.Tip="When enabled, dragging a scroll bar thumb won't affect the scrolling content until the pointer is released."
  21. Content="Enable Deferred Scrolling" />
  22. <StackPanel Orientation="Vertical"
  23. Spacing="4">
  24. <TextBlock Text="Horizontal Scroll" />
  25. <ComboBox ItemsSource="{Binding AvailableVisibility}"
  26. SelectedItem="{Binding HorizontalScrollVisibility}" />
  27. </StackPanel>
  28. <StackPanel Orientation="Vertical"
  29. Spacing="4">
  30. <TextBlock Text="Vertical Scroll" />
  31. <ComboBox ItemsSource="{Binding AvailableVisibility}"
  32. SelectedItem="{Binding VerticalScrollVisibility}" />
  33. </StackPanel>
  34. </StackPanel>
  35. <ScrollViewer x:Name="ScrollViewer"
  36. Grid.Column="1"
  37. Width="400"
  38. Height="400"
  39. IsScrollInertiaEnabled="{Binding EnableInertia}"
  40. AllowAutoHide="{Binding AllowAutoHide}"
  41. HorizontalScrollBarVisibility="{Binding HorizontalScrollVisibility}"
  42. VerticalScrollBarVisibility="{Binding VerticalScrollVisibility}">
  43. <Image Width="800"
  44. Height="800"
  45. Stretch="UniformToFill"
  46. Source="/Assets/delicate-arch-896885_640.jpg" />
  47. </ScrollViewer>
  48. </Grid>
  49. </StackPanel>
  50. </TabItem>
  51. <TabItem Header="Snapping">
  52. <StackPanel Orientation="Vertical"
  53. Spacing="4">
  54. <TextBlock TextWrapping="Wrap"
  55. Classes="h2">Scrollviewer can snap supported content both vertically and horizontally. Snapping occurs from scrolling with touch or pen.</TextBlock>
  56. <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto">
  57. <StackPanel Orientation="Horizontal"
  58. Spacing="4">
  59. <StackPanel Orientation="Vertical"
  60. Spacing="4">
  61. <TextBlock Text="Snap Point Type" />
  62. <ComboBox ItemsSource="{Binding AvailableSnapPointsType}"
  63. SelectedItem="{Binding SnapPointsType}" />
  64. </StackPanel>
  65. <StackPanel Orientation="Vertical"
  66. Spacing="4">
  67. <TextBlock Text="Snap Point Alignment" />
  68. <ComboBox ItemsSource="{Binding AvailableSnapPointsAlignment}"
  69. SelectedItem="{Binding SnapPointsAlignment}" />
  70. </StackPanel>
  71. <ToggleSwitch IsChecked="{Binding AreSnapPointsRegular}"
  72. OffContent="No"
  73. OnContent="Yes"
  74. Content="Are Snap Points regular?" />
  75. </StackPanel>
  76. <TextBlock TextWrapping="Wrap"
  77. Grid.Row="1"
  78. Margin="0,10"
  79. Classes="h2">Vertical Snapping</TextBlock>
  80. <Border
  81. BorderBrush="Green"
  82. BorderThickness="1"
  83. Padding="0"
  84. Grid.Row="2"
  85. Margin="10, 5">
  86. <ScrollViewer x:Name="VerticalSnapsScrollViewer"
  87. VerticalSnapPointsType="{Binding SnapPointsType}"
  88. VerticalSnapPointsAlignment="{Binding SnapPointsAlignment}"
  89. HorizontalAlignment="Stretch"
  90. Height="350"
  91. HorizontalScrollBarVisibility="Disabled">
  92. <StackPanel AreVerticalSnapPointsRegular="{Binding AreSnapPointsRegular}"
  93. Orientation="Vertical"
  94. HorizontalAlignment="Stretch">
  95. <Border Padding="5, 30"
  96. BorderBrush="Red"
  97. HorizontalAlignment="Stretch"
  98. BorderThickness="1">
  99. <TextBlock FontWeight="Bold"
  100. Text="Child 1"/>
  101. </Border>
  102. <Border Padding="5, 30"
  103. BorderBrush="Red"
  104. HorizontalAlignment="Stretch"
  105. BorderThickness="1">
  106. <TextBlock FontWeight="Bold"
  107. Text="Child 2"/>
  108. </Border>
  109. <Border Padding="5, 20"
  110. BorderBrush="Red"
  111. HorizontalAlignment="Stretch"
  112. BorderThickness="1">
  113. <TextBlock FontWeight="Bold"
  114. Text="Child 3"/>
  115. </Border>
  116. <Border Padding="5, 30"
  117. BorderBrush="Red"
  118. HorizontalAlignment="Stretch"
  119. BorderThickness="1">
  120. <TextBlock FontWeight="Bold"
  121. Text="Child 4"/>
  122. </Border>
  123. <Border Padding="5, 30"
  124. BorderBrush="Red"
  125. HorizontalAlignment="Stretch"
  126. BorderThickness="1">
  127. <TextBlock FontWeight="Bold"
  128. Text="Child 5"/>
  129. </Border>
  130. <Border Padding="5, 30"
  131. BorderBrush="Red"
  132. HorizontalAlignment="Stretch"
  133. BorderThickness="1">
  134. <TextBlock FontWeight="Bold"
  135. Text="Child 6"/>
  136. </Border>
  137. <Border Padding="5,8"
  138. BorderBrush="Red"
  139. HorizontalAlignment="Stretch"
  140. BorderThickness="1">
  141. <TextBlock FontWeight="Bold"
  142. Text="Child 7"/>
  143. </Border>
  144. <Border Padding="5, 30"
  145. BorderBrush="Red"
  146. HorizontalAlignment="Stretch"
  147. BorderThickness="1">
  148. <TextBlock FontWeight="Bold"
  149. Text="Child 8"/>
  150. </Border>
  151. <Border Padding="5,4"
  152. BorderBrush="Red"
  153. HorizontalAlignment="Stretch"
  154. BorderThickness="1">
  155. <TextBlock FontWeight="Bold"
  156. Text="Child 9"/>
  157. </Border>
  158. <Border Padding="5, 30"
  159. BorderBrush="Red"
  160. HorizontalAlignment="Stretch"
  161. BorderThickness="1">
  162. <TextBlock FontWeight="Bold"
  163. Text="Child 20"/>
  164. </Border>
  165. <Border Padding="5, 30"
  166. BorderBrush="Red"
  167. HorizontalAlignment="Stretch"
  168. BorderThickness="1">
  169. <TextBlock FontWeight="Bold"
  170. Text="Child 11"/>
  171. </Border>
  172. <Border Padding="5, 30"
  173. BorderBrush="Red"
  174. HorizontalAlignment="Stretch"
  175. BorderThickness="1">
  176. <TextBlock FontWeight="Bold"
  177. Text="Child 12"/>
  178. </Border>
  179. </StackPanel>
  180. </ScrollViewer>
  181. </Border>
  182. <TextBlock TextWrapping="Wrap"
  183. Grid.Row="3"
  184. Margin="0,10"
  185. Classes="h2">Horizontal Snapping</TextBlock>
  186. <Border
  187. BorderBrush="Green"
  188. BorderThickness="1"
  189. Padding="0"
  190. Grid.Row="4"
  191. Margin="10, 10">
  192. <ScrollViewer x:Name="HorizontalSnapsScrollViewer"
  193. HorizontalSnapPointsType="{Binding SnapPointsType}"
  194. HorizontalSnapPointsAlignment="{Binding SnapPointsAlignment}"
  195. HorizontalAlignment="Stretch"
  196. Height="350"
  197. HorizontalScrollBarVisibility="Auto"
  198. VerticalScrollBarVisibility="Disabled">
  199. <StackPanel AreHorizontalSnapPointsRegular="{Binding AreSnapPointsRegular}"
  200. Orientation="Horizontal"
  201. HorizontalAlignment="Stretch">
  202. <Border Padding="5, 30"
  203. Width="300"
  204. BorderBrush="Red"
  205. HorizontalAlignment="Stretch"
  206. BorderThickness="1">
  207. <TextBlock FontWeight="Bold"
  208. VerticalAlignment="Center"
  209. Text="Child 1"/>
  210. </Border>
  211. <Border Padding="5, 30"
  212. Width="300"
  213. BorderBrush="Red"
  214. VerticalAlignment="Stretch"
  215. BorderThickness="1">
  216. <TextBlock FontWeight="Bold"
  217. VerticalAlignment="Center"
  218. Text="Child 2"/>
  219. </Border>
  220. <Border Padding="5, 20"
  221. Width="300"
  222. BorderBrush="Red"
  223. VerticalAlignment="Stretch"
  224. BorderThickness="1">
  225. <TextBlock FontWeight="Bold"
  226. VerticalAlignment="Center"
  227. Text="Child 3"/>
  228. </Border>
  229. <Border Padding="5, 30"
  230. Width="300"
  231. BorderBrush="Red"
  232. VerticalAlignment="Stretch"
  233. BorderThickness="1">
  234. <TextBlock FontWeight="Bold"
  235. VerticalAlignment="Center"
  236. Text="Child 4"/>
  237. </Border>
  238. <Border Padding="5, 30"
  239. Width="300"
  240. BorderBrush="Red"
  241. VerticalAlignment="Stretch"
  242. BorderThickness="1">
  243. <TextBlock FontWeight="Bold"
  244. VerticalAlignment="Center"
  245. Text="Child 5"/>
  246. </Border>
  247. <Border Padding="5, 30"
  248. Width="300"
  249. BorderBrush="Red"
  250. VerticalAlignment="Stretch"
  251. BorderThickness="1">
  252. <TextBlock FontWeight="Bold"
  253. VerticalAlignment="Center"
  254. Text="Child 6"/>
  255. </Border>
  256. </StackPanel>
  257. </ScrollViewer>
  258. </Border>
  259. </Grid>
  260. </StackPanel>
  261. </TabItem>
  262. </TabControl>
  263. </UserControl>