Skip to content

Commit 547b7fa

Browse files
Change to show gesture leak
1 parent 3e5fb02 commit 547b7fa

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

MauiCollectionView/Views/PageXamlLeak.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
<CollectionView.ItemTemplate>
88
<DataTemplate>
99

10-
<Label Text="Test" />
10+
<Label Text="{Binding Name}">
11+
<Label.GestureRecognizers>
12+
<TapGestureRecognizer Command="{Binding BindingContext.Command}" />
13+
</Label.GestureRecognizers>
14+
</Label>
1115

1216
</DataTemplate>
1317
</CollectionView.ItemTemplate>

MauiCollectionView/Views/PageXamlLeak.xaml.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.ObjectModel;
2+
using System.Windows.Input;
23

34
namespace MauiCollectionView.Views;
45

@@ -9,11 +10,23 @@ public PageXamlLeak()
910
InitializeComponent();
1011

1112
var collectionView = (CollectionView)Content;
12-
collectionView.ItemsSource = new ObservableCollection<string> { "1", "2", "3" };
13+
collectionView.ItemsSource = new MyModel[]
14+
{
15+
"1", "2", "3"
16+
};
1317
}
1418

1519
~PageXamlLeak()
1620
{
1721
Console.WriteLine("~PageXamlLeak() called");
1822
}
23+
}
24+
25+
class MyModel
26+
{
27+
public static implicit operator MyModel(string value) => new() { Name = value };
28+
29+
public string Name { get; set; } = "";
30+
31+
public ICommand Command { get; set; } = new Command(() => Console.WriteLine("Tapped!"));
1932
}

0 commit comments

Comments
 (0)