|
12 | 12 | using Avalonia.Controls.Automation.Peers;
|
13 | 13 | using Avalonia.Controls.Metadata;
|
14 | 14 | using Avalonia.Controls.Mixins;
|
| 15 | +using Avalonia.Controls.Shapes; |
| 16 | +using Avalonia.Controls.Templates; |
15 | 17 | using Avalonia.Controls.Utils;
|
16 | 18 | using Avalonia.Data;
|
17 | 19 | using Avalonia.Input;
|
@@ -678,8 +680,7 @@ private void OnMouseMove_BeginReorder(Point mousePosition)
|
678 | 680 | {
|
679 | 681 | OwningColumn = OwningColumn,
|
680 | 682 | IsEnabled = false,
|
681 |
| - Content = Content, |
682 |
| - ContentTemplate = ContentTemplate |
| 683 | + Content = GetDragIndicatorContent(Content, ContentTemplate) |
683 | 684 | };
|
684 | 685 | if (OwningGrid.ColumnHeaderTheme is { } columnHeaderTheme)
|
685 | 686 | {
|
@@ -725,6 +726,36 @@ private void OnMouseMove_BeginReorder(Point mousePosition)
|
725 | 726 | }
|
726 | 727 | }
|
727 | 728 |
|
| 729 | + private object GetDragIndicatorContent(object content, IDataTemplate? dataTemplate) |
| 730 | + { |
| 731 | + if (content is ContentControl icc) |
| 732 | + { |
| 733 | + content = icc.Content; |
| 734 | + } |
| 735 | + |
| 736 | + if (content is Control control) |
| 737 | + { |
| 738 | + if (VisualRoot == null) return content; |
| 739 | + control.Measure(Size.Infinity); |
| 740 | + var rect = new Rectangle() |
| 741 | + { |
| 742 | + Width = control.DesiredSize.Width, |
| 743 | + Height = control.DesiredSize.Height, |
| 744 | + Fill = new VisualBrush |
| 745 | + { |
| 746 | + Visual = control, Stretch = Stretch.None, AlignmentX = AlignmentX.Left, |
| 747 | + } |
| 748 | + }; |
| 749 | + return rect; |
| 750 | + } |
| 751 | + |
| 752 | + if (dataTemplate is not null) |
| 753 | + { |
| 754 | + return dataTemplate.Build(content); |
| 755 | + } |
| 756 | + return content; |
| 757 | + } |
| 758 | + |
728 | 759 | //TODO DragEvents
|
729 | 760 | private void OnMouseMove_Reorder(ref bool handled, Point mousePosition, Point mousePositionHeaders)
|
730 | 761 | {
|
|
0 commit comments