diff --git a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs index 0c7408f16249..25f6062a70b9 100644 --- a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs @@ -19,6 +19,7 @@ #elif IOS || MACCATALYST using Microsoft.Maui.Controls.Compatibility.Platform.iOS; using Microsoft.Maui.Controls.Handlers.Compatibility; +using Microsoft.Maui.Controls.Handlers.Items2; #elif TIZEN using Microsoft.Maui.Controls.Handlers.Compatibility; using Microsoft.Maui.Controls.Compatibility.Platform.Tizen; @@ -61,8 +62,13 @@ public static partial class AppHostBuilderExtensions internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCollection handlersCollection) { +#if IOS || MACCATALYST + handlersCollection.AddHandler(); + handlersCollection.AddHandler(); +#else handlersCollection.AddHandler(); handlersCollection.AddHandler(); +#endif handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); diff --git a/src/Templates/src/templates/maui-mobile/MauiProgram.cs b/src/Templates/src/templates/maui-mobile/MauiProgram.cs index 43dd1272843c..32ebbe27ed96 100644 --- a/src/Templates/src/templates/maui-mobile/MauiProgram.cs +++ b/src/Templates/src/templates/maui-mobile/MauiProgram.cs @@ -18,14 +18,6 @@ public static MauiApp CreateMauiApp() #if (IncludeSampleContent) .UseMauiCommunityToolkit() .ConfigureSyncfusionToolkit() - .ConfigureMauiHandlers(handlers => - { -//-:cnd:noEmit -#if IOS || MACCATALYST - handlers.AddHandler(); -#endif -//+:cnd:noEmit - }) #endif .ConfigureFonts(fonts => { diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs index c9c1aa2711d8..a7bd1aa0cac5 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/SimpleTemplateTest.cs @@ -333,32 +333,4 @@ public void BuildWithDifferentVersionNumber(string id, string config, string dis Assert.IsTrue(DotnetInternal.Build(projectFile, config, properties: buildProps, msbuildWarningsAsErrors: true), $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); } - - // This test is super temporary and is just for the interim - // while we productize the CollectionViewHandler2. Once we - // ship it as the default, this test will fail and can be deleted. - [Test] - [TestCase("maui", DotNetCurrent, "", false)] - [TestCase("maui", DotNetCurrent, "--sample-content", true)] - public void SampleShouldHaveHandler2Registered(string id, string framework, string additionalDotNetNewParams, bool shouldHaveHandler2) - { - var projectDir = TestDirectory; - var programFile = Path.Combine(projectDir, "MauiProgram.cs"); - - Assert.IsTrue(DotnetInternal.New(id, projectDir, framework, additionalDotNetNewParams), - $"Unable to create template {id}. Check test output for errors."); - - var programContents = File.ReadAllText(programFile); - - if (shouldHaveHandler2) - { - AssertContains("#if IOS || MACCATALYST", programContents); - AssertContains("handlers.AddHandler();", programContents); - } - else - { - AssertDoesNotContain("#if IOS || MACCATALYST", programContents); - AssertDoesNotContain("handlers.AddHandler();", programContents); - } - } }