-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/Controls/tests/TestCases.HostApp/Issues/Issue20443.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Controls.TestCases.HostApp.Issues.Issue20443" | ||
xmlns:local="clr-namespace:Controls.TestCases.HostApp.Issues" | ||
x:DataType="local:Issue20443ViewModel" | ||
Title="Issue20443"> | ||
<ContentPage.BindingContext> | ||
<local:Issue20443ViewModel/> | ||
</ContentPage.BindingContext> | ||
<Grid> | ||
<RefreshView | ||
IsRefreshing="{Binding IsRefreshing}" | ||
Command="{Binding RefreshCommand}"> | ||
<CollectionView | ||
ItemSizingStrategy="MeasureAllItems" | ||
ItemsSource="{Binding Items}"> | ||
<CollectionView.ItemTemplate> | ||
<local:Issue20443TemplateSelector> | ||
<local:Issue20443TemplateSelector.ItemATemplate> | ||
<DataTemplate> | ||
<Grid | ||
HeightRequest="20" | ||
BackgroundColor="Aqua"> | ||
<Label Text="20"/> | ||
</Grid> | ||
</DataTemplate> | ||
</local:Issue20443TemplateSelector.ItemATemplate> | ||
<local:Issue20443TemplateSelector.ItemBTemplate> | ||
<DataTemplate> | ||
<Grid | ||
HeightRequest="100" | ||
BackgroundColor="Pink"> | ||
<Label Text="100"/> | ||
</Grid> | ||
</DataTemplate> | ||
</local:Issue20443TemplateSelector.ItemBTemplate> | ||
</local:Issue20443TemplateSelector> | ||
</CollectionView.ItemTemplate> | ||
|
||
</CollectionView> | ||
</RefreshView> | ||
</Grid> | ||
</ContentPage> |
90 changes: 90 additions & 0 deletions
90
src/Controls/tests/TestCases.HostApp/Issues/Issue20443.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace Controls.TestCases.HostApp.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 20443, "CollectionView item gets wrong size after refresh", PlatformAffected.iOS)] | ||
|
||
public partial class Issue20443 : ContentPage | ||
{ | ||
public Issue20443() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
public class Issue20443ViewModel : INotifyPropertyChanged | ||
{ | ||
public IList<object> Items { get; set; } | ||
|
||
private bool _isRefreshing; | ||
|
||
public bool IsRefreshing | ||
{ | ||
get => _isRefreshing; | ||
set | ||
{ | ||
_isRefreshing = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
|
||
public Command RefreshCommand { get; set; } | ||
|
||
public Issue20443ViewModel() | ||
{ | ||
RefreshCommand = new Command( | ||
async () => | ||
{ | ||
await Task.Delay(2000); | ||
IsRefreshing = false; | ||
}); | ||
|
||
Items = new List<object>(); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
Items.Add(new Issue20443ItemA()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
Items.Add(new Issue20443ItemB()); | ||
} | ||
} | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
|
||
public class Issue20443ItemA | ||
{ | ||
|
||
} | ||
|
||
public class Issue20443ItemB | ||
{ | ||
|
||
} | ||
|
||
public class Issue20443TemplateSelector : DataTemplateSelector | ||
{ | ||
public DataTemplate ItemATemplate { get; set; } | ||
public DataTemplate ItemBTemplate { get; set; } | ||
|
||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container) | ||
{ | ||
if (item is Issue20443ItemA) | ||
{ | ||
return ItemATemplate; | ||
} | ||
|
||
return ItemBTemplate; | ||
} | ||
} | ||
} |