Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
ClearSizeEstimate();
ReloadData();
}

Element.Dispatcher.DispatchIfRequired(() => List?.UpdateLayout());
}

protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Platform;
using Microsoft.UI.Xaml;
using Xunit;

namespace Microsoft.Maui.DeviceTests
{
Expand All @@ -14,5 +21,38 @@ void ValidatePlatformCells(ListView listView)
{

}

[Fact]
public async Task InsertItemWorks()
{
SetupBuilder();

var data = new ObservableCollection<string>();
var listView = new ListView()
{
ItemsSource = data
};

var layout = new VerticalStackLayout()
{
listView
};

await CreateHandlerAndAddToWindow<LayoutHandler>(layout, async (handler) =>
{
await Task.Delay(100);

data.Add("Item 1");
data.Add("Item 3");
data.Insert(1, "Item 2");

await Task.Delay(200);

var actualListView = listView.ToPlatform() as ListViewRenderer;
var textChildren = actualListView.GetChildren<UI.Xaml.Controls.TextBlock>();

Assert.Contains(textChildren, (x) => x.Text == "Item 3");
});
}
}
}
}