Open
Description
Description
The following works.
<CollectionView.ItemTemplate>
<OnPlatform x:TypeArguments="DataTemplate">
<On Platform="Android">
<DataTemplate>
<Label Text="{Binding .}" />
</DataTemplate>
</On>
<On Platform="WinUI">
<DataTemplate>
<Label Text="{Binding .}" BackgroundColor="Red" />
</DataTemplate>
</On>
</OnPlatform>
</CollectionView.ItemTemplate>
However the following does NOT work on both Windows and Android.
<CollectionView.Header>
<OnPlatform x:TypeArguments="View">
<On Platform="Android">
<Label Text="Android" />
</On>
<On Platform="WinUI">
<Label Text="WinUI" />
</On>
</OnPlatform>
</CollectionView.Header>
Steps to Reproduce
- Create a project from the default MAUI template.
- Use the following for the XAML of
MainPage
. Remove the unnecessary code in the defaultMainPage.cs
.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bug.MainPage">
<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" />
</On>
<On Platform="WinUI">
<Label Text="WinUI" />
</On>
</OnPlatform>
</CollectionView.Header>
</CollectionView>
</ContentPage>
Link to public reproduction project repository
No response
Version with bug
9.0.0-rc.1.24453.9
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No.
Relevant log output
No response