-
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.
[iOS] Add templated cells as children of the CollectionView2 (#26357)
* [testing] Add repo for issue #26066 * [iOS] Make sure to call disconnect handler * [iOS] TemplatedCell2 should be added as logical child * [testing] Add test for issue #26066 * [iOS] We just need container when is not template [iOS] Remove dispose [ios] Revert to view.SetValueFromRenderer Revert dispose changes Fix copy Add CV1 and CV2 hardcoded Revert "Revert dispose changes" This reverts commit 94affdd. Cleanup
- Loading branch information
Showing
5 changed files
with
129 additions
and
108 deletions.
There are no files selected for viewing
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
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
42 changes: 42 additions & 0 deletions
42
src/Controls/tests/TestCases.HostApp/Issues/Issue26066.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,42 @@ | ||
<?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="Maui.Controls.Sample.Issues.Issue26066" | ||
xmlns:sample="clr-namespace:Maui.Controls.Sample" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues" | ||
x:DataType="local:Issue26066ViewModel"> | ||
<ContentPage.BindingContext> | ||
<local:Issue26066ViewModel/> | ||
</ContentPage.BindingContext> | ||
<Grid RowDefinitions="Auto,*,Auto,*"> | ||
<Grid.Resources> | ||
<DataTemplate x:DataType="local:Issue22035Model" | ||
x:Key="template"> | ||
<StackLayout Padding="10" BackgroundColor="Lightgray"> | ||
<Button | ||
AutomationId="{Binding AutomationId}" | ||
Command="{Binding ShowDialogCommand, Source={x:RelativeSource AncestorType={x:Type local:Issue26066ViewModel}}, x:DataType=local:Issue26066ViewModel}" | ||
CommandParameter="{Binding .}" | ||
Text="{Binding Text}"/> | ||
</StackLayout> | ||
</DataTemplate> | ||
</Grid.Resources> | ||
<Button BackgroundColor="LightBlue" | ||
Grid.Row="0" | ||
AutomationId="TestLoadButtonCV2" | ||
Text="Load Items CV2" | ||
Command="{Binding LoadCommandCV2}"/> | ||
<sample:CollectionView2 Grid.Row="1" BackgroundColor="LightBlue" | ||
ItemsSource="{Binding Images2}" | ||
ItemTemplate="{StaticResource template}"/> | ||
<Button BackgroundColor="LightGreen " | ||
Grid.Row="2" | ||
AutomationId="TestLoadButtonCV" | ||
Text="Load Items CV1" | ||
Command="{Binding LoadCommand}"/> | ||
<sample:CollectionView1 Grid.Row="3" BackgroundColor="LightGreen" | ||
ItemsSource="{Binding Images}" | ||
ItemTemplate="{StaticResource template}"/> | ||
</Grid> | ||
</ContentPage> |
42 changes: 42 additions & 0 deletions
42
src/Controls/tests/TestCases.HostApp/Issues/Issue26066.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,42 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Windows.Input; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 26066, "CollectionViewHandler2 RelativeSource binding to AncestorType not working", PlatformAffected.Android | PlatformAffected.iOS)] | ||
public partial class Issue26066 : ContentPage | ||
{ | ||
public Issue26066() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
|
||
class Issue26066ViewModel | ||
{ | ||
public Issue26066ViewModel() | ||
{ | ||
LoadCommand.Execute(null); | ||
LoadCommandCV2.Execute(null); | ||
} | ||
|
||
public ObservableCollection<Issue22035Model> Images { get; set; } = new(); | ||
public ObservableCollection<Issue22035Model> Images2 { get; set; } = new(); | ||
|
||
public ICommand ShowDialogCommand => new Command(async () => await Application.Current.MainPage.DisplayAlert("New Dialog", "Hello from Espinho", "OK")); | ||
|
||
public ICommand LoadCommand => new Command(() => LoadItems(Images, "CV1")); | ||
|
||
public ICommand LoadCommandCV2 => new Command(() => LoadItems(Images2, "CV2")); | ||
|
||
static void LoadItems(ObservableCollection<Issue22035Model> items, string text) | ||
{ | ||
items.Clear(); | ||
for (int i = 0; i < 3 ; i++) | ||
{ | ||
items.Add(new Issue22035Model { Text = $"{text} - Item {i}", ImagePath = i% 2 == 0 ? "photo21314.jpg" : "oasis.jpg" }); | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26066.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,23 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue26066(TestDevice testDevice) : _IssuesUITest(testDevice) | ||
{ | ||
public override string Issue => "CollectionViewHandler2 RelativeSource binding to AncestorType not working"; | ||
|
||
[Test] | ||
[Category(UITestCategories.CollectionView)] | ||
public void CollectionView2ShouldFindAncestorType() | ||
{ | ||
var text = "CV2"; | ||
var i = 1; | ||
var automationId = $"{text} - Item {i}".Replace(" ", "", StringComparison.Ordinal); | ||
App.WaitForElement(automationId); | ||
App.Click(automationId); | ||
App.WaitForElement("OK"); | ||
App.Click("OK"); | ||
} | ||
} |