Skip to content

Commit

Permalink
Change to show gesture leak
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpeppers committed Apr 17, 2024
1 parent 3e5fb02 commit 547b7fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion MauiCollectionView/Views/PageXamlLeak.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
<CollectionView.ItemTemplate>
<DataTemplate>

<Label Text="Test" />
<Label Text="{Binding Name}">
<Label.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.Command}" />
</Label.GestureRecognizers>
</Label>

</DataTemplate>
</CollectionView.ItemTemplate>
Expand Down
15 changes: 14 additions & 1 deletion MauiCollectionView/Views/PageXamlLeak.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Windows.Input;

namespace MauiCollectionView.Views;

Expand All @@ -9,11 +10,23 @@ public PageXamlLeak()
InitializeComponent();

var collectionView = (CollectionView)Content;
collectionView.ItemsSource = new ObservableCollection<string> { "1", "2", "3" };
collectionView.ItemsSource = new MyModel[]
{
"1", "2", "3"
};
}

~PageXamlLeak()
{
Console.WriteLine("~PageXamlLeak() called");
}
}

class MyModel
{
public static implicit operator MyModel(string value) => new() { Name = value };

public string Name { get; set; } = "";

public ICommand Command { get; set; } = new Command(() => Console.WriteLine("Tapped!"));
}

0 comments on commit 547b7fa

Please sign in to comment.