-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/1520-BindingExpressionTests
- Loading branch information
Showing
63 changed files
with
2,878 additions
and
848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui"> | ||
<StackPanel Orientation="Vertical" Gap="4"> | ||
<TextBlock Classes="h1">Drag+Drop</TextBlock> | ||
<TextBlock Classes="h2">Example of Drag+Drop capabilities</TextBlock> | ||
|
||
<StackPanel Orientation="Horizontal" | ||
Margin="0,16,0,0" | ||
HorizontalAlignment="Center" | ||
Gap="16"> | ||
<Border BorderBrush="{DynamicResource ThemeAccentBrush}" BorderThickness="2" Padding="16" Name="DragMe"> | ||
<TextBlock Name="DragState">Drag Me</TextBlock> | ||
</Border> | ||
<Border Background="{DynamicResource ThemeAccentBrush2}" Padding="16" | ||
DragDrop.AllowDrop="True"> | ||
<TextBlock Name="DropState">Drop some text or files here</TextBlock> | ||
</Border> | ||
</StackPanel> | ||
</StackPanel> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Input; | ||
using Avalonia.Markup.Xaml; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace ControlCatalog.Pages | ||
{ | ||
public class DragAndDropPage : UserControl | ||
{ | ||
private TextBlock _DropState; | ||
private TextBlock _DragState; | ||
private Border _DragMe; | ||
private int DragCount = 0; | ||
|
||
public DragAndDropPage() | ||
{ | ||
this.InitializeComponent(); | ||
|
||
_DragMe.PointerPressed += DoDrag; | ||
|
||
AddHandler(DragDrop.DropEvent, Drop); | ||
AddHandler(DragDrop.DragOverEvent, DragOver); | ||
} | ||
|
||
private async void DoDrag(object sender, Avalonia.Input.PointerPressedEventArgs e) | ||
{ | ||
DataObject dragData = new DataObject(); | ||
dragData.Set(DataFormats.Text, $"You have dragged text {++DragCount} times"); | ||
|
||
var result = await DragDrop.DoDragDrop(dragData, DragDropEffects.Copy); | ||
switch(result) | ||
{ | ||
case DragDropEffects.Copy: | ||
_DragState.Text = "The text was copied"; break; | ||
case DragDropEffects.Link: | ||
_DragState.Text = "The text was linked"; break; | ||
case DragDropEffects.None: | ||
_DragState.Text = "The drag operation was canceled"; break; | ||
} | ||
} | ||
|
||
private void DragOver(object sender, DragEventArgs e) | ||
{ | ||
// Only allow Copy or Link as Drop Operations. | ||
e.DragEffects = e.DragEffects & (DragDropEffects.Copy | DragDropEffects.Link); | ||
|
||
// Only allow if the dragged data contains text or filenames. | ||
if (!e.Data.Contains(DataFormats.Text) && !e.Data.Contains(DataFormats.FileNames)) | ||
e.DragEffects = DragDropEffects.None; | ||
} | ||
|
||
private void Drop(object sender, DragEventArgs e) | ||
{ | ||
if (e.Data.Contains(DataFormats.Text)) | ||
_DropState.Text = e.Data.GetText(); | ||
else if (e.Data.Contains(DataFormats.FileNames)) | ||
_DropState.Text = string.Join(Environment.NewLine, e.Data.GetFileNames()); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
|
||
_DropState = this.Find<TextBlock>("DropState"); | ||
_DragState = this.Find<TextBlock>("DragState"); | ||
_DragMe = this.Find<Border>("DragMe"); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.