DragDropPage.axaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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="IntegrationTestApp.Pages.DragDropPage">
  7. <DockPanel>
  8. <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="4">
  9. <Button Name="ResetDragDrop" Click="ResetDragDrop_Click" Margin="0,0,8,0">Reset</Button>
  10. <TextBlock VerticalAlignment="Center">Drop Position: </TextBlock>
  11. <TextBlock Name="DropPosition" VerticalAlignment="Center" Margin="4,0"/>
  12. <TextBlock VerticalAlignment="Center" Margin="8,0,0,0">Status: </TextBlock>
  13. <TextBlock Name="DragDropStatus" VerticalAlignment="Center" Margin="4,0"/>
  14. </StackPanel>
  15. <!-- Use a Grid with row definitions to create offset from window origin -->
  16. <!-- The top spacer ensures the drag/drop controls are NOT at (0,0) -->
  17. <Grid RowDefinitions="100,*">
  18. <!-- Spacer row to offset controls from window origin -->
  19. <Border Grid.Row="0" Background="LightGray">
  20. <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
  21. Text="Spacer (100px) - Controls below are offset from window origin"/>
  22. </Border>
  23. <!-- Drag and Drop test area -->
  24. <Grid Grid.Row="1" ColumnDefinitions="*,*" Margin="20">
  25. <!-- Drag Source -->
  26. <Border Name="DragSource"
  27. Grid.Column="0"
  28. Background="CornflowerBlue"
  29. Margin="10"
  30. CornerRadius="8"
  31. AutomationProperties.AccessibilityView="Content"
  32. PointerPressed="DragSource_PointerPressed">
  33. <TextBlock HorizontalAlignment="Center"
  34. VerticalAlignment="Center"
  35. Text="Drag Source"
  36. Foreground="White"
  37. FontWeight="Bold"/>
  38. </Border>
  39. <!-- Drop Target -->
  40. <Border Name="DropTarget"
  41. Grid.Column="1"
  42. Background="LightGreen"
  43. Margin="10"
  44. CornerRadius="8"
  45. AutomationProperties.AccessibilityView="Content"
  46. DragDrop.AllowDrop="True">
  47. <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
  48. <TextBlock Text="Drop Target"
  49. HorizontalAlignment="Center"
  50. FontWeight="Bold"/>
  51. <TextBlock Name="DropTargetText"
  52. HorizontalAlignment="Center"
  53. Text="Drop items here"/>
  54. </StackPanel>
  55. </Border>
  56. </Grid>
  57. </Grid>
  58. </DockPanel>
  59. </UserControl>