Skip to content

Fix IndicatorTemplate in IndicatorView does not update when set dynamically without initial value - #40133

Merged
kubaflo merged 8 commits into
dotnet:candidate/11.0.1xx-sr2from
devanathan-vaithiyanathan:fix-31128
Nov 19, 2026
Merged

kubaflo merged 8 commits into
dotnet:candidate/11.0.1xx-sr2from
devanathan-vaithiyanathan:fix-31128

Conversation

@devanathan-vaithiyanathan

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details:

When using IndicatorView, if the IndicatorTemplate property is not set initially and is assigned later, the new template is not applied on all platforms.

Root cause:

Changing IndicatorTemplate creates a managed layout, but doesn’t notify the native handler to display it. iOS/Windows only attached that layout during initial connection.

Description of Changes:

IndicatorView.cs now notifies the handler after the template updates and detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform implementations for dynamically switching templates and restoring default indicators when cleared.

Issues Fixed

Fixes #31128

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
Android
Before-31128.mov
Android
After-31128.mov

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40133

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40133"

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 10, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 4 findings

Reviewed commit 801219e.

See inline comments for details.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot added s/agent-gate-failed AI could not verify tests catch the bug and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 10, 2026
@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 12, 2026
@kubaflo

kubaflo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-gate-failed AI could not verify tests catch the bug labels Nov 12, 2026
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 17, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

Reviewed commit 5ed10ec.

See inline comments for details.

@MauiBot

This comment has been minimized.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 17, 2026
@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@devanathan-vaithiyanathan — test-failure analysis for commit 5ed10ec.

Scope CI failures Commit 5ed10ec


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests

🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Inspect device termination, compare equivalent OS/handlers/screenshots, and restore missing diagnostics.

Maintainers: comment /review tests to refresh this report.

@sheiksyedm
sheiksyedm marked this pull request as ready for review November 19, 2026 07:32
Copilot AI balanced review requested due to automatic review settings November 19, 2026 07:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new screenshot test lacks the baseline required by the iOS 18.5 CoreCLR lane, causing it to fail even when the template renders correctly.

2 open issues
What changed in this PR

Fixes #31128 by propagating dynamic IndicatorTemplate changes from the Controls layer to native IndicatorView handlers.

Changes:

  • Notifies handlers when templates change and detaches old layout subscriptions.
  • Updates platform handlers to replace templates and restore default indicators when cleared.
  • Adds dynamic-template UI coverage and a Windows selection-color regression test.
File Description
src/​Core/​tests/​DeviceTests/​Handlers/​IndicatorView/​IndicatorViewHandlerTests.Windows.cs Tests selection beyond the visible indicator limit.
src/​Core/​src/​Platform/​Windows/​MauiPageControl.cs Uses the visible index for selection colors.
src/​Core/​src/​Platform/​iOS/​UIPageControlExtensions.cs Adjusts single-page hiding for templates.
src/​Core/​src/​Platform/​iOS/​MauiPageControl.cs Manages template attachment, removal, and native indicator restoration.
src/​Core/​src/​Platform/​Android/​MauiPageControl.cs Adds braces around the existing shape-reset branch.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.Windows.cs Maps dynamic template changes and restores default indicators.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.Standard.cs Adds the standard-platform mapper stub.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.iOS.cs Maps template changes and refreshes single-page visibility.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.cs Registers the template-layout mapping.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.Android.cs Rebuilds indicators when the template changes.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue31128.cs Adds screenshot verification after dynamic template assignment.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue31128.cs Adds a reproduction page with an assignment button.
src/​Controls/​src/​Core/​IndicatorView/​IndicatorView.cs Notifies handlers, invalidates measurement, and detaches old subscriptions.

Review effort: Balanced

App.WaitForElement("AssignIndicatorTemplate");
App.Tap("AssignIndicatorTemplate");

VerifyScreenshot();
=> UpdateIndicatorLayout((IndicatorView)bindable, newValue), propertyChanged: (bindable, oldValue, newValue) =>
{
var indicatorView = (IndicatorView)bindable;
indicatorView.Handler?.UpdateValue(nameof(ITemplatedIndicatorView.IndicatorsLayoutOverride));
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 3 findings

Reviewed commit 5ed10ec.

See inline comments for details.

#if __IOS__ || MACCATALYST
[nameof(IView.FlowDirection)] = MapFlowDirection,
#endif
[nameof(ITemplatedIndicatorView.IndicatorsLayoutOverride)] = MapIndicatorsLayoutOverride

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Handler Mapper and Property Patterns - During initial handler setup, this mapping runs after IndicatorsShape even when IndicatorTemplate is null. Android removes and recreates the indicator children, and Windows replaces them through CreateIndicators(). An existing AppendToMapping(nameof(IIndicatorView.IndicatorsShape), ...) customization that sets those children's opacity or margins therefore executes but loses its changes before first display; previously those children survived the last indicator mapping. Neither rebuild reapplies the customized property mapping. Avoid rebuilding an already-untemplated control during initialization, and preserve property-mapper customizations when rebuilding.

App.WaitForElement("AssignIndicatorTemplate");
App.Tap("AssignIndicatorTemplate");

VerifyScreenshot();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - The iOS baseline exists only under snapshots/ios-26. On iOS 18.5, VerifyScreenshot selects snapshots/ios, and VisualRegressionTester requires that exact environment's file without fallback. The frozen ui-tests.yml also explicitly selects 18.5 for the CoreCLR latest lane. Consequently this assertion fails with 'Baseline snapshot not yet created' even when the custom labels render correctly. Add the snapshots/ios baseline or assert the displayed custom labels directly.

public void DynamicallyAssignedIndicatorTemplateDisplaysCustomLabels()
{
App.WaitForElement("AssignIndicatorTemplate");
App.Tap("AssignIndicatorTemplate");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[moderate] Regression Prevention and Test Coverage - This test stops after null-to-template assignment, so it cannot detect an old native template host surviving replacement or native dots failing to return after clearing IndicatorTemplate. Those replacement/restoration branches are added on Android, iOS/MacCatalyst and Windows, but the existing managed null-layout and weak-reference tests have no native handler, and the new Windows selection test never attaches a template. Add a distinct template A-to-B-to-null sequence asserting A disappears, B appears and native dots return on all four platforms. Include IndicatorSize=20, assign a template, reset size to 6, then clear it on iOS/MacCatalyst: the new size guard/cache reset intersects #35214 (fixed by #35215), while the existing native-only size-reset test misses that transition.

@MauiBot

MauiBot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@devanathan-vaithiyanathan — existing-test verification for commit 5ed10eca.

Result PASSED Platform Android Commit 5ed10eca


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

🖥 UI tests
Test group Without fix With fix
Issue31128 ✅ Failed as expected (576s) ✅ Passed (1439s)
Execution log excerpts

Without fix Issue31128

     at VisualTestUtils.VisualRegressionTester.Fail(String message) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 162
   at VisualTestUtils.VisualRegressionTester.VerifyMatchesSnapshot(String name, ImageSnapshot actualImage, String environmentName, ITestContext testContext) in /_/src/TestUtils/src/VisualTestUtils/VisualRegressionTester.cs:line 123
   at Microsoft.Maui.TestCases.Tests.UITest.<VerifyScreenshot>g__Verify|13_0(String name, <>c__DisplayClass13_0&) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 488
   at Microsoft.Maui.TestCases.Tests.UITest.VerifyScreenshot(String name, Nullable`1 retryDelay, Nullable`1 retryTimeout, Int32 cropLeft, Int32 cropRight, Int32 cropTop, Int32 cropBottom, Double tolerance) in /_/src/Controls/tests/TestCases.Shared.Tests/UITest.cs:line 312
   at Microsoft.Maui.TestCases.Tests.Issues.Issue31128.DynamicallyAssignedIndicatorTemplateDisplaysCustomLabels() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31128.cs:line 22
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

With fix Issue31128

/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: Timed out waiting for data from device. [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: adb: failed to install /home/vsts/work/1/s/artifacts/bin/Controls.TestCases.HostApp/Debug/net11.0-android/com.microsoft.maui.uitests-Signed.apk: cmd: Failure calling service package: Broken pipe (32) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: ADB transport recovery: [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010: Recovery failed: System.TimeoutException: Timed out waiting for the Android package manager on device 'emulator-5554' after 10 seconds. Last response: exit code 20: cmd: Can't find service: package [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Android.Sdk.Linux/37.2.15/tools/Xamarin.Android.Common.Debugging.targets(378,5): error ADB0010:    at Xamarin.Android.Tools.AdbRunner.WaitForPackageManagerAsync(String serial, Nullable`1 timeout, TimeSpan pollInterval, CancellationToken cancellationToken) [/home/vsts/work/1/s/src/Controls/tests/TestCases.HostApp/Controls.TestCases.HostApp.csproj::TargetFramework=net11.0-android]
/home/vsts/work/1/s/.dotnet/packs/Microsoft.Andr

PR head: 5ed10eca.

Without-fix baseline: 331056d8.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 19, 2026
@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 19, 2026 11:02
@kubaflo
kubaflo merged commit f28fd4f into dotnet:candidate/11.0.1xx-sr2 Nov 19, 2026
157 of 184 checks passed
@kubaflo kubaflo mentioned this pull request Nov 19, 2026
1 task
kubaflo added a commit that referenced this pull request Nov 19, 2026
…ically without initial value (#40133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Details:
When using IndicatorView, if the IndicatorTemplate property is not set
initially and is assigned later, the new template is not applied on all
platforms.
 
### Root cause: 
Changing IndicatorTemplate creates a managed layout, but doesn’t notify
the native handler to display it. iOS/Windows only attached that layout
during initial connection.
 
### Description of Changes:
IndicatorView.cs now notifies the handler after the template updates and
detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform
implementations for dynamically switching templates and restoring
default indicators when cleared.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #31128 

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

**Tested the behavior in the following platforms.**
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

| Before  | After  |
|---------|--------|
| **Android**<br> <video
src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44"
width="300" height="600"> | **Android**<br> <video
src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a"
width="300" height="600"> |

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…ically without initial value (#40133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Details:
When using IndicatorView, if the IndicatorTemplate property is not set
initially and is assigned later, the new template is not applied on all
platforms.
 
### Root cause: 
Changing IndicatorTemplate creates a managed layout, but doesn’t notify
the native handler to display it. iOS/Windows only attached that layout
during initial connection.
 
### Description of Changes:
IndicatorView.cs now notifies the handler after the template updates and
detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform
implementations for dynamically switching templates and restoring
default indicators when cleared.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #31128 

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

**Tested the behavior in the following platforms.**
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

| Before  | After  |
|---------|--------|
| **Android**<br> <video
src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44"
width="300" height="600"> | **Android**<br> <video
src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a"
width="300" height="600"> |

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…ically without initial value (#40133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Details:
When using IndicatorView, if the IndicatorTemplate property is not set
initially and is assigned later, the new template is not applied on all
platforms.
 
### Root cause: 
Changing IndicatorTemplate creates a managed layout, but doesn’t notify
the native handler to display it. iOS/Windows only attached that layout
during initial connection.
 
### Description of Changes:
IndicatorView.cs now notifies the handler after the template updates and
detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform
implementations for dynamically switching templates and restoring
default indicators when cleared.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #31128 

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

**Tested the behavior in the following platforms.**
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

| Before  | After  |
|---------|--------|
| **Android**<br> <video
src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44"
width="300" height="600"> | **Android**<br> <video
src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a"
width="300" height="600"> |

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…ically without initial value (dotnet#40133)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Issue Details:
When using IndicatorView, if the IndicatorTemplate property is not set
initially and is assigned later, the new template is not applied on all
platforms.
 
### Root cause: 
Changing IndicatorTemplate creates a managed layout, but doesn’t notify
the native handler to display it. iOS/Windows only attached that layout
during initial connection.
 
### Description of Changes:
IndicatorView.cs now notifies the handler after the template updates and
detaches the old layout’s event subscription.
IndicatorViewHandler.cs now maps IndicatorsLayoutOverride, with platform
implementations for dynamically switching templates and restoring
default indicators when cleared.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes dotnet#31128 

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

**Tested the behavior in the following platforms.**
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

| Before  | After  |
|---------|--------|
| **Android**<br> <video
src="https://github.com/user-attachments/assets/47d726c9-2efb-44bf-a08d-9c8d8cde2d44"
width="300" height="600"> | **Android**<br> <video
src="https://github.com/user-attachments/assets/ca3979cd-4f21-4577-87f8-6b6b8963cc6a"
width="300" height="600"> |

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndicatorTemplate in IndicatorView does not update when set dynamically without initial value

5 participants