Skip to content

Commit d8164f4

Browse files
pictosPedro Jesus
andauthored
remove reflection (#11)
Co-authored-by: Pedro Jesus <pedrojesus@Pedros-MacBook-Pro.local>
1 parent 78d419b commit d8164f4

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

src/PJ.ContextActions.Maui/CollectionView/PJCollectionViewHandler.windows.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Maui.Controls.Handlers.Items;
2+
using Microsoft.Maui.Controls.Platform;
23
using Microsoft.UI.Xaml.Controls;
34
using WMenuFlyout = Microsoft.UI.Xaml.Controls.MenuFlyout;
45
using WMenuFlyoutItem = Microsoft.UI.Xaml.Controls.MenuFlyoutItem;
@@ -49,7 +50,7 @@ protected virtual void OnContainerContentChanging(ListViewBase sender, Container
4950
}
5051

5152
var menuFlyout = new WMenuFlyout();
52-
var model = args.Item.ToCollectionViewModel();
53+
var model = ((ItemTemplateContext)args.Item).Item;
5354

5455
mauiCommand ??= new Command<CommandBag>(static bag =>
5556
{

src/PJ.ContextActions.Maui/Helpers.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@ static class Helpers
1212
where T : class
1313
=> weak.TryGetTarget(out var value) ? value : default;
1414
#if WINDOWS
15-
static Type? itemTemplateContextType;
16-
17-
public static object ToCollectionViewModel(this object item)
18-
{
19-
itemTemplateContextType ??= item.GetType();
20-
21-
var propertyInfo = itemTemplateContextType.GetProperty("Item", Instance | Public);
22-
23-
Assert(propertyInfo is not null);
24-
25-
var value = propertyInfo.GetValue(item, null);
26-
27-
Assert(value is not null);
28-
29-
return value;
30-
}
31-
3215
public static IconElement? CreateIconElementFromIconPath(this string iconPath)
3316
{
3417
try

0 commit comments

Comments
 (0)