You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
using System.Collections.ObjectModel;
|
|
using DragNDrop.Model;
|
|
|
|
namespace DragNDrop;
|
|
|
|
public partial class ExchangeNounoursPage : ContentPage
|
|
{
|
|
public ObservableCollection<Nounours> FirstCollection { get; set; } = new ObservableCollection<Nounours>()
|
|
{
|
|
new Nounours(42, "Chewbacca"),
|
|
new Nounours(43, "Yoda"),
|
|
new Nounours(44, "Ewok"),
|
|
new Nounours(45, "Jabba the Hutt"),
|
|
new Nounours(666, "Chucky")
|
|
};
|
|
|
|
public ObservableCollection<Nounours> SecondCollection { get; set; } = new ObservableCollection<Nounours>();
|
|
|
|
public ExchangeNounoursPage()
|
|
{
|
|
InitializeComponent();
|
|
BindingContext = this;
|
|
}
|
|
|
|
private void OnDragStarting(object sender, DragStartingEventArgs e)
|
|
{
|
|
e.Data.Properties["value"] = (sender as Element)?.BindingContext;
|
|
}
|
|
|
|
private void OnDrop(object sender, DropEventArgs e)
|
|
{
|
|
var collection = ((sender as Element)?.Parent as FlexLayout).GetPropertyIfSet<ObservableCollection<Nounours>>(BindableLayout.ItemsSourceProperty, null);
|
|
if (e.Data.Properties["value"] is Nounours nounours)
|
|
{
|
|
FirstCollection.Remove(nounours);
|
|
SecondCollection.Remove(nounours);
|
|
collection.Add(nounours);
|
|
}
|
|
}
|
|
} |