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

Fixed Header and Footer template is not visible in CollectionView #26844

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -108,7 +108,7 @@ protected virtual void UpdateHeader()
_currentHeader = null;
}

var header = ItemsView.Header;
var header = ItemsView.Header ?? ItemsView.HeaderTemplate;

switch (header)
{
Expand All @@ -133,7 +133,7 @@ protected virtual void UpdateHeader()
if (headerTemplate != null)
{
ListViewBase.HeaderTemplate = ItemsViewTemplate;
ListViewBase.Header = new ItemTemplateContext(headerTemplate, header, Element);
ListViewBase.Header = new ItemTemplateContext(headerTemplate, header, Element, mauiContext: MauiContext);
}
else
{
Expand All @@ -157,7 +157,7 @@ protected virtual void UpdateFooter()
_currentFooter = null;
}

var footer = ItemsView.Footer;
var footer = ItemsView.Footer ?? ItemsView.FooterTemplate;

switch (footer)
{
Expand All @@ -182,7 +182,7 @@ protected virtual void UpdateFooter()
if (footerTemplate != null)
{
ListViewBase.FooterTemplate = ItemsViewTemplate;
ListViewBase.Footer = new ItemTemplateContext(footerTemplate, footer, Element);
ListViewBase.Footer = new ItemTemplateContext(footerTemplate, footer, Element, mauiContext: MauiContext);
}
else
{
Expand Down
3 changes: 0 additions & 3 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue8761.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<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>
Expand Down Expand Up @@ -33,5 +31,4 @@
</DataTemplate>
</CollectionView.FooterTemplate>
</CollectionView>

</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if ANDROID
// https://github.com/dotnet/maui/issues/22892
using NUnit.Framework;
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

Expand All @@ -25,5 +23,4 @@ public void CollectionViewHeaderTemplateAndFooterTemplateDontWork()
App.WaitForElement("FooterLabel");
}
}
}
#endif
}