ScrollSnapPage.xaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  4. d:DesignHeight="800"
  5. d:DesignWidth="400"
  6. x:Class="ControlCatalog.Pages.ScrollSnapPage"
  7. xmlns:pages="using:ControlCatalog.Pages"
  8. x:DataType="pages:ScrollSnapPageViewModel">
  9. <StackPanel Orientation="Vertical" Spacing="4">
  10. <TextBlock TextWrapping="Wrap"
  11. Classes="h2">Scrollviewer can snap supported content both vertically and horizontally. Snapping occurs from scrolling with touch or pen.</TextBlock>
  12. <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto">
  13. <StackPanel Orientation="Horizontal"
  14. Spacing="4">
  15. <StackPanel Orientation="Vertical"
  16. Spacing="4">
  17. <TextBlock Text="Snap Point Type" />
  18. <ComboBox ItemsSource="{Binding AvailableSnapPointsType}"
  19. SelectedItem="{Binding SnapPointsType}" />
  20. </StackPanel>
  21. <StackPanel Orientation="Vertical"
  22. Spacing="4">
  23. <TextBlock Text="Snap Point Alignment" />
  24. <ComboBox ItemsSource="{Binding AvailableSnapPointsAlignment}"
  25. SelectedItem="{Binding SnapPointsAlignment}" />
  26. </StackPanel>
  27. <ToggleSwitch IsChecked="{Binding AreSnapPointsRegular}"
  28. OffContent="No"
  29. OnContent="Yes"
  30. Content="Are Snap Points regular?" />
  31. </StackPanel>
  32. <TextBlock TextWrapping="Wrap"
  33. Grid.Row="1"
  34. Margin="0,10"
  35. Classes="h2">Vertical Snapping</TextBlock>
  36. <Border
  37. BorderBrush="Green"
  38. BorderThickness="1"
  39. Padding="0"
  40. Grid.Row="2"
  41. Margin="10, 5">
  42. <ScrollViewer x:Name="VerticalSnapsScrollViewer"
  43. VerticalSnapPointsType="{Binding SnapPointsType}"
  44. VerticalSnapPointsAlignment="{Binding SnapPointsAlignment}"
  45. HorizontalAlignment="Stretch"
  46. Height="350"
  47. HorizontalScrollBarVisibility="Disabled">
  48. <StackPanel AreVerticalSnapPointsRegular="{Binding AreSnapPointsRegular}"
  49. Orientation="Vertical"
  50. HorizontalAlignment="Stretch">
  51. <Border Padding="5, 30"
  52. BorderBrush="Red"
  53. HorizontalAlignment="Stretch"
  54. BorderThickness="1">
  55. <TextBlock FontWeight="Bold"
  56. Text="Child 1"/>
  57. </Border>
  58. <Border Padding="5, 30"
  59. BorderBrush="Red"
  60. HorizontalAlignment="Stretch"
  61. BorderThickness="1">
  62. <TextBlock FontWeight="Bold"
  63. Text="Child 2"/>
  64. </Border>
  65. <Border Padding="5, 20"
  66. BorderBrush="Red"
  67. HorizontalAlignment="Stretch"
  68. BorderThickness="1">
  69. <TextBlock FontWeight="Bold"
  70. Text="Child 3"/>
  71. </Border>
  72. <Border Padding="5, 30"
  73. BorderBrush="Red"
  74. HorizontalAlignment="Stretch"
  75. BorderThickness="1">
  76. <TextBlock FontWeight="Bold"
  77. Text="Child 4"/>
  78. </Border>
  79. <Border Padding="5, 30"
  80. BorderBrush="Red"
  81. HorizontalAlignment="Stretch"
  82. BorderThickness="1">
  83. <TextBlock FontWeight="Bold"
  84. Text="Child 5"/>
  85. </Border>
  86. <Border Padding="5, 30"
  87. BorderBrush="Red"
  88. HorizontalAlignment="Stretch"
  89. BorderThickness="1">
  90. <TextBlock FontWeight="Bold"
  91. Text="Child 6"/>
  92. </Border>
  93. <Border Padding="5,8"
  94. BorderBrush="Red"
  95. HorizontalAlignment="Stretch"
  96. BorderThickness="1">
  97. <TextBlock FontWeight="Bold"
  98. Text="Child 7"/>
  99. </Border>
  100. <Border Padding="5, 30"
  101. BorderBrush="Red"
  102. HorizontalAlignment="Stretch"
  103. BorderThickness="1">
  104. <TextBlock FontWeight="Bold"
  105. Text="Child 8"/>
  106. </Border>
  107. <Border Padding="5,4"
  108. BorderBrush="Red"
  109. HorizontalAlignment="Stretch"
  110. BorderThickness="1">
  111. <TextBlock FontWeight="Bold"
  112. Text="Child 9"/>
  113. </Border>
  114. <Border Padding="5, 30"
  115. BorderBrush="Red"
  116. HorizontalAlignment="Stretch"
  117. BorderThickness="1">
  118. <TextBlock FontWeight="Bold"
  119. Text="Child 20"/>
  120. </Border>
  121. <Border Padding="5, 30"
  122. BorderBrush="Red"
  123. HorizontalAlignment="Stretch"
  124. BorderThickness="1">
  125. <TextBlock FontWeight="Bold"
  126. Text="Child 11"/>
  127. </Border>
  128. <Border Padding="5, 30"
  129. BorderBrush="Red"
  130. HorizontalAlignment="Stretch"
  131. BorderThickness="1">
  132. <TextBlock FontWeight="Bold"
  133. Text="Child 12"/>
  134. </Border>
  135. </StackPanel>
  136. </ScrollViewer>
  137. </Border>
  138. <TextBlock TextWrapping="Wrap"
  139. Grid.Row="3"
  140. Margin="0,10"
  141. Classes="h2">Horizontal Snapping</TextBlock>
  142. <Border
  143. BorderBrush="Green"
  144. BorderThickness="1"
  145. Padding="0"
  146. Grid.Row="4"
  147. Margin="10, 10">
  148. <ScrollViewer x:Name="HorizontalSnapsScrollViewer"
  149. HorizontalSnapPointsType="{Binding SnapPointsType}"
  150. HorizontalSnapPointsAlignment="{Binding SnapPointsAlignment}"
  151. HorizontalAlignment="Stretch"
  152. Height="350"
  153. HorizontalScrollBarVisibility="Auto"
  154. VerticalScrollBarVisibility="Disabled">
  155. <StackPanel AreHorizontalSnapPointsRegular="{Binding AreSnapPointsRegular}"
  156. Orientation="Horizontal"
  157. HorizontalAlignment="Stretch">
  158. <Border Padding="5, 30"
  159. Width="300"
  160. BorderBrush="Red"
  161. HorizontalAlignment="Stretch"
  162. BorderThickness="1">
  163. <TextBlock FontWeight="Bold"
  164. VerticalAlignment="Center"
  165. Text="Child 1"/>
  166. </Border>
  167. <Border Padding="5, 30"
  168. Width="300"
  169. BorderBrush="Red"
  170. VerticalAlignment="Stretch"
  171. BorderThickness="1">
  172. <TextBlock FontWeight="Bold"
  173. VerticalAlignment="Center"
  174. Text="Child 2"/>
  175. </Border>
  176. <Border Padding="5, 20"
  177. Width="300"
  178. BorderBrush="Red"
  179. VerticalAlignment="Stretch"
  180. BorderThickness="1">
  181. <TextBlock FontWeight="Bold"
  182. VerticalAlignment="Center"
  183. Text="Child 3"/>
  184. </Border>
  185. <Border Padding="5, 30"
  186. Width="300"
  187. BorderBrush="Red"
  188. VerticalAlignment="Stretch"
  189. BorderThickness="1">
  190. <TextBlock FontWeight="Bold"
  191. VerticalAlignment="Center"
  192. Text="Child 4"/>
  193. </Border>
  194. <Border Padding="5, 30"
  195. Width="300"
  196. BorderBrush="Red"
  197. VerticalAlignment="Stretch"
  198. BorderThickness="1">
  199. <TextBlock FontWeight="Bold"
  200. VerticalAlignment="Center"
  201. Text="Child 5"/>
  202. </Border>
  203. <Border Padding="5, 30"
  204. Width="300"
  205. BorderBrush="Red"
  206. VerticalAlignment="Stretch"
  207. BorderThickness="1">
  208. <TextBlock FontWeight="Bold"
  209. VerticalAlignment="Center"
  210. Text="Child 6"/>
  211. </Border>
  212. </StackPanel>
  213. </ScrollViewer>
  214. </Border>
  215. </Grid>
  216. </StackPanel>
  217. </UserControl>