diff --git a/src/Controls/src/Core/SwipeView/SwipeView.Mapper.cs b/src/Controls/src/Core/SwipeView/SwipeView.Mapper.cs new file mode 100644 index 000000000000..1b1f918451d6 --- /dev/null +++ b/src/Controls/src/Core/SwipeView/SwipeView.Mapper.cs @@ -0,0 +1,39 @@ +using System; +using Microsoft.Maui.Controls.Compatibility; + +namespace Microsoft.Maui.Controls +{ + public partial class SwipeView + { + [Obsolete("Use SwipeViewHandler.Mapper instead.")] + internal static IPropertyMapper ControlsSwipeMapper = + new ControlsMapper(SwipeViewHandler.Mapper); + + internal static new void RemapForControls() + { + // Adjusted the mapping to preserve SwipeView.Entry legacy behavior + SwipeViewHandler.Mapper.AppendToMapping(nameof(Background), MapBackground); + } + + static void MapBackground(ISwipeViewHandler handler, SwipeView swipeView) + { + if (swipeView.Content is not null) + { + var contentBackgroundIsNull = Brush.IsNullOrEmpty(swipeView.Content.Background); + var contentBackgroundColorIsNull = swipeView.Content.BackgroundColor == null; + + if (contentBackgroundIsNull && contentBackgroundColorIsNull) + { + if (!Brush.IsNullOrEmpty(swipeView.Background)) + { + swipeView.Content.Background = swipeView.Background; + } + else if (swipeView.BackgroundColor != null) + { + swipeView.Content.BackgroundColor = swipeView.BackgroundColor; + } + } + } + } + } +} diff --git a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs index 50eeb913fc75..c7a02e335a49 100644 --- a/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Xaml/Hosting/AppHostBuilderExtensions.cs @@ -242,6 +242,7 @@ internal static MauiAppBuilder RemapForControls(this MauiAppBuilder builder) Window.RemapForControls(); Editor.RemapForControls(); Entry.RemapForControls(); + SwipeView.RemapForControls(); Picker.RemapForControls(); SearchBar.RemapForControls(); TabbedPage.RemapForControls();