Skip to content
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
11 changes: 11 additions & 0 deletions src/Controls/src/Core/Xaml/TypeConversionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ internal static object ConvertTo(this object value, Type toType, Func<TypeConver
}
}

// When toType is object and value is OnPlatform<T>, we need to return the wrapped value from IWrappedView
if (toType is object && value is IWrappedValue { Value: var wrappedValue })
{
if (wrappedValue is null)
{
return value;
}

return wrappedValue;
}

var platformValueConverterService = DependencyService.Get<INativeValueConverterService>();

object platformValue = null;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25124.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue25124"
Title="Issue25124">
<Grid>
<CollectionView AutomationId="CollectionView">
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>A</x:String>
<x:String>B</x:String>
</x:Array>
</CollectionView.ItemsSource>
<CollectionView.Header>
<OnPlatform x:TypeArguments="View">
<On Platform="Android">
<Label Text="Android Header"/>
</On>
<On Platform="WinUI">
<Label Text="WinUI Header"/>
</On>
<On Platform="iOS">
<Label Text="IOS Header"/>
</On>
<On Platform="MacCatalyst">
<Label Text="Mac Header"/>
</On>
</OnPlatform>
</CollectionView.Header>
</CollectionView>
</Grid>
</ContentPage>
10 changes: 10 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue25124.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 25124, "OnPlatform does not work in the Header and Footer of CollectionView", PlatformAffected.UWP | PlatformAffected.Android | PlatformAffected.iOS | PlatformAffected.macOS)]
public partial class Issue25124 : ContentPage
{
public Issue25124()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue25124 : _IssuesUITest
{
public Issue25124(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "OnPlatform does not work in the Header and Footer of CollectionView";

[Test]
[Category(UITestCategories.CollectionView)]
public void ShouldDisplayHeaderBasedOnOnPlatform()
{
App.WaitForElement("CollectionView");
VerifyScreenshot();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.