-
Notifications
You must be signed in to change notification settings - Fork 2k
Fix for Android - Dynamic Updates to CollectionView Header/Footer and Templates Are Not Displayed #28904
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
Merged
kubaflo
merged 11 commits into
dotnet:inflight/current
from
SuthiYuvaraj:fix-28676-preview
May 24, 2026
Merged
Fix for Android - Dynamic Updates to CollectionView Header/Footer and Templates Are Not Displayed #28904
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7524bac
commit for fix changes
SuthiYuvaraj ac09058
testcase changes
SuthiYuvaraj 73509d7
Update Issue28676Template.cs
SuthiYuvaraj e6058e4
Update Issue28676.cs
SuthiYuvaraj 9fdf59d
Code changes
SuthiYuvaraj d25e39d
Update StructuredItemsViewAdapter.cs
SuthiYuvaraj a3a1fad
Update src/Controls/tests/TestCases.HostApp/Issues/Issue28676Template.cs
SuthiYuvaraj 2d45923
Merge branch 'main' into fix-28676-preview
SuthiYuvaraj c631535
Update StructuredItemsViewHandler.Android.cs
SuthiYuvaraj 0d110e4
Testcase removed and enabled 28509
SuthiYuvaraj d7e75bc
Update StructuredItemsViewAdapter.cs
SuthiYuvaraj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
178 changes: 178 additions & 0 deletions
178
src/Controls/tests/TestCases.HostApp/Issues/Issue28676.cs
This file contains hidden or 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,178 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [Issue(IssueTracker.Github, 28676, "Android Dynamic Updates to CollectionView Header and Footer Are Not Displayed", | ||
| PlatformAffected.Android)] | ||
| public class Issue28676 : ContentPage | ||
| { | ||
| private Label headerLabel; | ||
| private Label footerLabel; | ||
| private CollectionView collectionView; | ||
| private ObservableCollection<string> items; | ||
|
|
||
|
|
||
| public Issue28676() | ||
| { | ||
|
|
||
| items = new ObservableCollection<string> | ||
| { | ||
| "Item 1", "Item 2", "Item 3" | ||
| }; | ||
|
|
||
| // Header and Footer Labels | ||
| headerLabel = new Label | ||
| { | ||
| Text = "Initial Header", | ||
| AutomationId = "Issue28676Header", | ||
| BackgroundColor = Colors.LightBlue, | ||
| FontAttributes = FontAttributes.Bold, | ||
| Padding = 10 | ||
| }; | ||
|
|
||
| footerLabel = new Label | ||
| { | ||
| Text = "Initial Footer", | ||
| AutomationId = "Issue28676Footer", | ||
| BackgroundColor = Colors.LightGray, | ||
| Padding = 10 | ||
| }; | ||
|
|
||
| // CollectionView | ||
| collectionView = new CollectionView | ||
| { | ||
| ItemsSource = items, | ||
| AutomationId = "Issue28676CollectionView", | ||
| Header = headerLabel, | ||
| Footer = footerLabel, | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var stack = new StackLayout | ||
| { | ||
| Padding = 10, | ||
| Spacing = 10 | ||
| }; | ||
|
|
||
| var label = new Label(); | ||
| label.SetBinding(Label.TextProperty, "."); | ||
|
|
||
| stack.Children.Add(label); | ||
| return stack; | ||
| }) | ||
| }; | ||
|
|
||
| // Top Grid with 2x2 Buttons | ||
| var topGrid = new Grid | ||
| { | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition(GridLength.Auto), | ||
| new RowDefinition(GridLength.Auto) | ||
| }, | ||
| ColumnDefinitions = | ||
| { | ||
| new ColumnDefinition(GridLength.Star), | ||
| new ColumnDefinition(GridLength.Star) | ||
| }, | ||
| Padding = 10, | ||
| RowSpacing = 10, | ||
| ColumnSpacing = 10 | ||
| }; | ||
|
|
||
| var button1 = new Button { Text = "Update Header", AutomationId = "Issue28676UpdateHeaderButton", }; | ||
| button1.Clicked += (s, e) => collectionView.Header = "UpdatedCollectionViewHeader"; | ||
|
|
||
| var button2 = new Button { Text = "Update Footer", AutomationId = "Issue28676UpdateFooterButton", }; | ||
| button2.Clicked += (s, e) => collectionView.Footer = "UpdatedCollectionViewFooter"; | ||
|
|
||
| var button3 = new Button { Text = "ChangeHeaderView", AutomationId = "Issue28676ChangeHeaderView", }; | ||
| button3.Clicked += OnChangeHeaderView; | ||
|
|
||
| var button4 = new Button { Text = "ChangeFooterView", AutomationId = "Issue28676ChangeFooterView", }; | ||
| button4.Clicked += OnChangeFooterView; | ||
|
|
||
| topGrid.Add(button1, 0, 0); | ||
| topGrid.Add(button2, 1, 0); | ||
| topGrid.Add(button3, 0, 1); | ||
| topGrid.Add(button4, 1, 1); | ||
|
|
||
| // Main Grid Layout | ||
| var mainGrid = new Grid | ||
| { | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| mainGrid.Add(topGrid, 0, 0); | ||
| mainGrid.Add(collectionView, 0, 1); | ||
|
|
||
| Content = mainGrid; | ||
| } | ||
|
|
||
| private void OnChangeHeaderView(object sender, EventArgs e) | ||
| { | ||
| var newHeaderGrid = new Grid | ||
| { | ||
| Padding = 10, | ||
| AutomationId = "Issue28676HeaderView", | ||
| BackgroundColor = Colors.LightGreen, | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto } | ||
| }, | ||
| ColumnDefinitions = | ||
| { | ||
| new ColumnDefinition { Width = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| var headerLabel = new Label | ||
| { | ||
| Text = "Updated HeaderView", | ||
| FontAttributes = FontAttributes.Bold, | ||
| FontSize = 16, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| TextColor = Colors.Black | ||
| }; | ||
|
|
||
| newHeaderGrid.Add(headerLabel, 0, 0); | ||
| collectionView.Header = newHeaderGrid; | ||
| } | ||
|
|
||
| private void OnChangeFooterView(object sender, EventArgs e) | ||
| { | ||
| var newHeaderGrid = new Grid | ||
| { | ||
| Padding = 10, | ||
| AutomationId = "Issue28676FooterView", | ||
| BackgroundColor = Colors.LightCyan, | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto } | ||
| }, | ||
| ColumnDefinitions = | ||
| { | ||
| new ColumnDefinition { Width = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| var headerLabel = new Label | ||
| { | ||
| Text = "Updated FooterView", | ||
| FontAttributes = FontAttributes.Bold, | ||
| FontSize = 16, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| TextColor = Colors.Black | ||
| }; | ||
|
|
||
| newHeaderGrid.Add(headerLabel, 0, 0); | ||
| collectionView.Footer = newHeaderGrid; | ||
| } | ||
| } | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please check?