Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Fixed Collection View header and footer update #20210

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,41 @@
<?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.Issue19379"
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues">
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Label
AutomationId="WaitForStubControl"
Text="Issue 19379"/>
<CollectionView
Header="{Binding CustomHeader, Mode=TwoWay}"
ItemsSource="{Binding ItemList}">
<CollectionView.HeaderTemplate>
<DataTemplate>
<ContentView>
<Label
Text="{Binding Title}"
BackgroundColor="Yellow"
Margin="0,10"/>
</ContentView>
</DataTemplate>
</CollectionView.HeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate>
<Label
Text="{Binding .}"
BackgroundColor="SkyBlue"
Margin="10"
VerticalOptions="Center"
VerticalTextAlignment="Center"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Button
AutomationId="UpdateButton"
Text="Update the CollectionView header"
Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 19379, "Not able to update CollectionView header", PlatformAffected.iOS)]
public partial class Issue19379 : ContentPage
{
int _initValue;
IList<string> _itemList;
Issue19379CustomHeader _customHeader;

public Issue19379()
{
InitializeComponent();
BindingContext = this;

PopulateList();
CustomHeader = new Issue19379CustomHeader
{
Title = "This is a CollectionViewHeader"
};
}

void Button_Clicked(object sender, EventArgs e)
{
_initValue++;
CustomHeader = new Issue19379CustomHeader
{
Title = $"This is a CollectionViewHeader #{_initValue}"
};
}

void PopulateList()
{
ItemList = new List<string>()
{
"This is an item",
"This is an item",
"This is an item",
"This is an item",
"This is an item",
"This is an item"
};
}

protected override void OnAppearing()
{
base.OnAppearing();
}



public IList<string> ItemList
{
get { return _itemList; }
set
{
_itemList = value;
OnPropertyChanged();
}
}

public Issue19379CustomHeader CustomHeader
{
get { return _customHeader; }
set
{
_customHeader = value;
OnPropertyChanged();
}
}
}

public class Issue19379CustomHeader
{
public string Title { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public CollectionViewHandler(PropertyMapper mapper = null) : base(mapper ?? Mapp
[Controls.ItemsView.IsVisibleProperty.PropertyName] = MapIsVisible,
[Controls.ItemsView.ItemsUpdatingScrollModeProperty.PropertyName] = MapItemsUpdatingScrollMode,
[StructuredItemsView.HeaderTemplateProperty.PropertyName] = MapHeaderTemplate,
[StructuredItemsView.HeaderProperty.PropertyName] = MapHeaderTemplate,
[StructuredItemsView.FooterProperty.PropertyName] = MapFooterTemplate,
rmarinho marked this conversation as resolved.
Show resolved Hide resolved
[StructuredItemsView.FooterTemplateProperty.PropertyName] = MapFooterTemplate,
[StructuredItemsView.ItemsLayoutProperty.PropertyName] = MapItemsLayout,
[StructuredItemsView.ItemSizingStrategyProperty.PropertyName] = MapItemSizingStrategy,
Expand Down
29 changes: 29 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue19379.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue19379 : _IssuesUITest
{
public Issue19379(TestDevice device)
: base(device)
{ }

public override string Issue => "Not able to update CollectionView header";

[Test]
public void UpdateCollectionViewHeaderTest()
{
this.IgnoreIfPlatforms(new TestDevice[] { TestDevice.Android, TestDevice.Mac, TestDevice.Windows });

App.WaitForElement("WaitForStubControl");

// 1. Update the CollectionView Header.
App.Click("UpdateButton");

// 2. Verify the result.
VerifyScreenshot();
jsuarezruiz marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Loading