-
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.
Fix Android CollectionVIew Header and Footer Template (#22889)
- Loading branch information
Showing
5 changed files
with
106 additions
and
3 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
29 changes: 29 additions & 0 deletions
29
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue8761.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,29 @@ | ||
#if ANDROID | ||
// https://github.com/dotnet/maui/issues/22892 | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue8761 : _IssuesUITest | ||
{ | ||
public override string Issue => "CollectionView Header Template and Footer Template don't work"; | ||
|
||
public Issue8761(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
[Test] | ||
[Category(UITestCategories.CollectionView)] | ||
public void CollectionViewHeaderTemplateAndFooterTemplateDontWork() | ||
{ | ||
for( int i = 0; i < 4; i++) | ||
{ | ||
App.WaitForElement("AddItem"); | ||
App.Tap("AddItem"); | ||
App.WaitForElement("FooterLabel"); | ||
} | ||
} | ||
} | ||
#endif |
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,37 @@ | ||
<?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" | ||
xmlns:local="clr-namespace:MauiCollectionViewFooterBug" | ||
x:Class="Maui.Controls.Sample.Issues.Issue8761"> | ||
|
||
<CollectionView ItemsSource="{Binding Items}"> | ||
<CollectionView.HeaderTemplate> | ||
<DataTemplate> | ||
<Button | ||
HorizontalOptions="Center" | ||
Margin="12,24" | ||
Text="Add Item" | ||
AutomationId="AddItem" | ||
Clicked="AddItem" /> | ||
</DataTemplate> | ||
</CollectionView.HeaderTemplate> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<Label Text="{Binding Identifier}" Margin="12,0" /> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
|
||
<CollectionView.FooterTemplate> | ||
<DataTemplate> | ||
<Label | ||
Text="Footer" | ||
HorizontalOptions="Center" | ||
AutomationId="FooterLabel" | ||
Margin="12,24" /> | ||
</DataTemplate> | ||
</CollectionView.FooterTemplate> | ||
</CollectionView> | ||
|
||
</ContentPage> |
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,27 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
public sealed class ListItem | ||
{ | ||
public string Identifier { get; } = Guid.NewGuid().ToString("D"); | ||
} | ||
|
||
[Issue(IssueTracker.Github, 8761, "CollectionView Header Template and Footer Template don't work", PlatformAffected.Android)] | ||
public partial class Issue8761 : ContentPage | ||
{ | ||
public ObservableCollection<ListItem> Items { get; } = new(); | ||
|
||
public Issue8761() | ||
{ | ||
BindingContext = this; | ||
InitializeComponent(); | ||
} | ||
|
||
private void AddItem(object sender, EventArgs e) | ||
{ | ||
Items.Add(new ListItem()); | ||
} | ||
} |
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