TestArrangementOfElements.axaml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
  6. x:Class="EntranseTesting.TestArrangementOfElements"
  7. x:DataType="vm:MainWindowViewModel"
  8. xmlns:vm="using:EntranseTesting.ViewModels">
  9. <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
  10. <StackPanel Margin="20 0" Background="Transparent" Spacing="15"
  11. HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  12. <!-- Задание -->
  13. <TextBlock Text="{Binding TestMain.TestPages.TestAE.Question}"
  14. VerticalAlignment="Top"
  15. HorizontalAlignment="Stretch"
  16. TextWrapping="Wrap"/>
  17. <!-- Картинки -->
  18. <ItemsRepeater ItemsSource="{Binding TestMain.TestPages.TestAE.QImage}"
  19. HorizontalAlignment="Stretch"
  20. VerticalAlignment="Stretch">
  21. <ItemsRepeater.Layout>
  22. <WrapLayout HorizontalSpacing="15" VerticalSpacing="5" Orientation="Horizontal"/>
  23. </ItemsRepeater.Layout>
  24. <ItemsRepeater.ItemTemplate>
  25. <DataTemplate>
  26. <Image Source="{Binding qImage}" Classes="Test"/>
  27. </DataTemplate>
  28. </ItemsRepeater.ItemTemplate>
  29. </ItemsRepeater>
  30. <!-- Поля с перетаскиванием -->
  31. <Grid Name="MainContainer" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
  32. <Border DragDrop.AllowDrop="True"
  33. CornerRadius="5" Background="Transparent" BorderThickness="0" Margin="0 5">
  34. <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  35. <ItemsRepeater ItemsSource="{Binding TestMain.TestPages.TestAE.Element}"
  36. VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
  37. <ItemsRepeater.Layout>
  38. <StackLayout Spacing="10" Orientation="{Binding TestMain.TestPages.TestAE.StackLayoutOrientation}"/>
  39. </ItemsRepeater.Layout>
  40. <ItemsRepeater.ItemTemplate>
  41. <DataTemplate>
  42. <Border PointerPressed="OnPointerPressed"
  43. Padding="10 5" Margin="0 0 0 15"
  44. Classes="Arrangment"
  45. HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
  46. Background="#cfd7ff" CornerRadius="5">
  47. <TextBlock Text="{Binding Name}"
  48. TextAlignment="Center"
  49. VerticalAlignment="Center"
  50. TextWrapping="Wrap"/>
  51. </Border>
  52. </DataTemplate>
  53. </ItemsRepeater.ItemTemplate>
  54. </ItemsRepeater>
  55. </ScrollViewer>
  56. </Border>
  57. </Grid>
  58. <!-- Полупрозрачный элемент == перетаскиваемому объекту -->
  59. <Border Name="GhostItem"
  60. Padding="10 5" CornerRadius="5"
  61. Classes="Arrangment"
  62. Background="#cfd7ff" Opacity="0.6"
  63. HorizontalAlignment="Center" VerticalAlignment="Center">
  64. <TextBlock Text="{Binding TestMain.TestPages.TestAE.DraggingElementItem.Name, FallbackValue='TEXT'}"
  65. Foreground="Black"
  66. TextAlignment="Center"
  67. TextWrapping="Wrap"
  68. VerticalAlignment="Center"
  69. MaxWidth="140"/>
  70. </Border>
  71. </StackPanel>
  72. </ScrollViewer>
  73. </UserControl>