CarouselDataBindingPage.xaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:pages="clr-namespace:ControlCatalog.Pages"
  4. x:Class="ControlCatalog.Pages.CarouselDataBindingPage">
  5. <DockPanel>
  6. <ScrollViewer DockPanel.Dock="Right" Width="260">
  7. <StackPanel Margin="12" Spacing="8">
  8. <TextBlock Text="Collection" FontWeight="SemiBold" FontSize="16"
  9. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  10. <TextBlock Text="Navigation" FontWeight="SemiBold" FontSize="13" />
  11. <Button x:Name="PreviousButton" Content="Previous" HorizontalAlignment="Stretch" />
  12. <Button x:Name="NextButton" Content="Next" HorizontalAlignment="Stretch" />
  13. <Separator />
  14. <TextBlock Text="Modify Items" FontWeight="SemiBold" FontSize="13" />
  15. <TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.6"
  16. Text="The Carousel is bound to an ObservableCollection. Changes reflect immediately." />
  17. <Button x:Name="AddButton" Content="Add Item" HorizontalAlignment="Stretch" />
  18. <Button x:Name="RemoveButton" Content="Remove Current" HorizontalAlignment="Stretch" />
  19. <Button x:Name="ShuffleButton" Content="Shuffle" HorizontalAlignment="Stretch" />
  20. <Separator />
  21. <TextBlock Text="Status" FontWeight="SemiBold" FontSize="14" />
  22. <TextBlock x:Name="StatusText" Text="Item: 1 / 4"
  23. Opacity="0.7" TextWrapping="Wrap" />
  24. </StackPanel>
  25. </ScrollViewer>
  26. <Border DockPanel.Dock="Right" Width="1"
  27. Background="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
  28. <Border Margin="12"
  29. BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
  30. BorderThickness="1" CornerRadius="6" ClipToBounds="True">
  31. <Carousel x:Name="DemoCarousel"
  32. Height="280"
  33. IsSwipeEnabled="True">
  34. <Carousel.PageTransition>
  35. <CrossFade Duration="0.3" />
  36. </Carousel.PageTransition>
  37. <Carousel.ItemTemplate>
  38. <DataTemplate x:DataType="pages:CarouselCardItem">
  39. <Border CornerRadius="14" Margin="14,12" ClipToBounds="True"
  40. Background="{Binding Background}">
  41. <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="8">
  42. <TextBlock Text="{Binding Number}" FontSize="52" FontWeight="Bold"
  43. Foreground="White" HorizontalAlignment="Center" LetterSpacing="-2" />
  44. <TextBlock Text="{Binding Title}" FontSize="15" FontWeight="SemiBold"
  45. Foreground="{Binding Accent}" HorizontalAlignment="Center" />
  46. </StackPanel>
  47. </Border>
  48. </DataTemplate>
  49. </Carousel.ItemTemplate>
  50. </Carousel>
  51. </Border>
  52. </DockPanel>
  53. </UserControl>