diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml
index 12dfe3095..15ddcb597 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml
@@ -74,7 +74,7 @@
-
+
@@ -96,6 +96,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ExpanderViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ExpanderViewModel.cs
index 016006abd..99ce10138 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ExpanderViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ExpanderViewModel.cs
@@ -20,7 +20,10 @@ public static IEnumerable GetContentCreators() =>
new("Kym Phillpotts", "https://kymphillpotts.com", "https://avatars.githubusercontent.com/u/1327346"),
new("Pedro Jesus", "https://github.com/pictos", "https://avatars.githubusercontent.com/u/20712372"),
new("Shaun Lawrence", "https://github.com/bijington", "https://avatars.githubusercontent.com/u/17139988"),
- new("Vladislav Antonyuk", "https://vladislavantonyuk.azurewebsites.net", "https://avatars.githubusercontent.com/u/33021114"),
+ new("Vladislav Antonyuk", "https://vladislavantonyuk.github.io", "https://avatars.githubusercontent.com/u/33021114"),
+ new("Víctor Hugo García Hernández", "", "https://avatars.githubusercontent.com/u/1047398"),
+ new("James Crutchley", "", "https://avatars.githubusercontent.com/u/4167863"),
+ new("Clifford Agius", "https://cliffordagius.co.uk/", "https://avatars.githubusercontent.com/u/5613809"),
];
}
}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui/Views/Expander/Expander.macios.cs b/src/CommunityToolkit.Maui/Views/Expander/Expander.macios.cs
deleted file mode 100644
index 22b06b644..000000000
--- a/src/CommunityToolkit.Maui/Views/Expander/Expander.macios.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using CoreGraphics;
-using UIKit;
-
-namespace CommunityToolkit.Maui.Views;
-
-public partial class Expander
-{
- static void ForceUpdateCellSize(CollectionView collectionView, Size size, Point? tapLocation)
- {
- if (tapLocation is null)
- {
- return;
- }
-
- var controller = GetController(collectionView);
-
- if (controller?.CollectionView.CollectionViewLayout is UICollectionViewFlowLayout layout)
- {
- var cells = layout.CollectionView.VisibleCells.OrderBy(x => x.Frame.Y).ToArray();
- var clickedCell = GetCellByPoint(cells, new CGPoint(tapLocation.Value.X, tapLocation.Value.Y));
- if (clickedCell is null)
- {
- return;
- }
-
- for (int i = 0; i < cells.Length; i++)
- {
- var cell = cells[i];
-
- if (i > 0)
- {
- var prevCellFrame = cells[i - 1].Frame;
- cell.Frame = new CGRect(cell.Frame.X, prevCellFrame.Y + prevCellFrame.Height, cell.Frame.Width, cell.Frame.Height);
- }
-
- if (cell.Equals(clickedCell))
- {
- cell.Frame = new CGRect(cell.Frame.X, cell.Frame.Y, cell.Frame.Width, size.Height);
- }
- }
- }
- }
-
- static UICollectionViewController? GetController(CollectionView collectionView)
- {
- var handler = collectionView.Handler as Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler;
- return handler?.Controller;
- }
-
- static UICollectionViewCell? GetCellByPoint(UICollectionViewCell[] cells, CGPoint point)
- {
- return cells.FirstOrDefault(cell => cell.Frame.Contains(point));
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs b/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
index b0afe23e6..ea092c2cf 100644
--- a/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
+++ b/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
@@ -169,33 +169,31 @@ void ResizeExpanderInItemsView(TappedEventArgs tappedEventArgs)
}
Element element = this;
+#if WINDOWS
var size = IsExpanded
? Measure(double.PositiveInfinity, double.PositiveInfinity)
: Header.Measure(double.PositiveInfinity, double.PositiveInfinity);
-
+#endif
while (element is not null)
{
- if (element.Parent is ListView && element is Cell cell)
- {
#if IOS || MACCATALYST
- throw new NotSupportedException($"{nameof(Expander)} is not yet supported in {nameof(ListView)}");
-#else
- cell.ForceUpdateSize();
+ if (element is ListView listView)
+ {
+ (listView.Handler?.PlatformView as UIKit.UITableView)?.ReloadData();
+ }
#endif
+
+#if WINDOWS
+ if (element.Parent is ListView listView && element is Cell cell)
+ {
+ cell.ForceUpdateSize();
}
-#if IOS || MACCATALYST || WINDOWS
else if (element is CollectionView collectionView)
{
var tapLocation = tappedEventArgs.GetPosition(collectionView);
ForceUpdateCellSize(collectionView, size, tapLocation);
}
#endif
-#if IOS || MACCATALYST
- else if (element is ScrollView scrollView)
- {
- ((IView)scrollView).InvalidateMeasure();
- }
-#endif
element = element.Parent;
}
diff --git a/src/CommunityToolkit.Maui/Views/Expander/Expander.windows.cs b/src/CommunityToolkit.Maui/Views/Expander/Expander.windows.cs
index 5f83587d8..54dca5830 100644
--- a/src/CommunityToolkit.Maui/Views/Expander/Expander.windows.cs
+++ b/src/CommunityToolkit.Maui/Views/Expander/Expander.windows.cs
@@ -1,4 +1,3 @@
-using CommunityToolkit.Maui.Core.Extensions;
using Microsoft.Maui.Controls.Platform;
using Microsoft.UI.Xaml.Controls;
@@ -30,5 +29,48 @@ static void ForceUpdateCellSize(CollectionView collectionView, Size size, Point?
}
}
}
+ else if (collectionView.Handler?.PlatformView is FormsGridView gridView)
+ {
+ var numberOfColumns = gridView.Span;
+ if (numberOfColumns == 0)
+ {
+ return;
+ }
+
+ for (var i = 0; i < gridView.Items.Count; i++)
+ {
+ if (gridView.ContainerFromIndex(i) is GridViewItem gridViewItem)
+ {
+ var itemTransform = gridViewItem.TransformToVisual(gridView);
+ var itemPosition = itemTransform.TransformPoint(new Windows.Foundation.Point(0, 0));
+ var itemBounds = new Rect(itemPosition.X, itemPosition.Y, gridViewItem.ActualWidth, gridViewItem.ActualHeight);
+
+ if (itemBounds.Contains(tapLocation.Value))
+ {
+ IterateItemsInRow(gridView, i, numberOfColumns, size.Height);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ static void IterateItemsInRow(ItemsControl gridView, int itemIndex, int totalColumns, double height)
+ {
+ var rowToIterate = itemIndex / totalColumns;
+ var startIndex = rowToIterate * totalColumns;
+
+ for (var i = startIndex; i < startIndex + totalColumns; i++)
+ {
+ if (i >= gridView.Items.Count)
+ {
+ break;
+ }
+
+ if (gridView.ContainerFromIndex(i) is GridViewItem cell)
+ {
+ cell.Height = height + Random.Shared.NextDouble();
+ }
+ }
}
}
\ No newline at end of file