Skip to content

[XSG] SwipeItems collection as StaticResource not handled correctly #33870

@StephaneDelcroix

Description

@StephaneDelcroix

Description

XAML Source Generator (XSG) does not correctly handle SwipeItems (a non-visual collection type) when defined as a resource and then referenced via StaticResource in LeftItems/RightItems properties.

Reproduction

<ContentPage.Resources>
    <ResourceDictionary>
        <SwipeItems x:Key="FavouriteSwipeItems">
            <SwipeItem
                Text="Favourite"
                IconImageSource="calculator.png"
                BackgroundColor="Yellow"
                Command="{Binding Source={x:Reference SwipeCollectionView}, Path=BindingContext.FavouriteCommand}"/>
        </SwipeItems>

        <SwipeItems x:Key="DeleteSwipeItems" Mode="Execute">
            <SwipeItem
                Text="Delete"
                IconImageSource="coffee.png"
                BackgroundColor="Red"
                Command="{Binding Source={x:Reference SwipeCollectionView}, Path=BindingContext.DeleteCommand}"/>
        </SwipeItems>

        <DataTemplate x:Key="MessageTemplate">
            <SwipeView
                HeightRequest="80"
                LeftItems="{StaticResource FavouriteSwipeItems}"
                RightItems="{StaticResource DeleteSwipeItems}">
                <!-- content -->
            </SwipeView>
        </DataTemplate>
    </ResourceDictionary>
</ContentPage.Resources>

Affected Files

Multiple files in src/Controls/samples/Controls.Sample/Pages/Controls/SwipeViewGalleries/:

  • ResourceSwipeItemsGallery.xaml
  • And potentially other SwipeView gallery files

Workaround

Use Inflator="Runtime" for the affected XAML files.

Context

Discovered while enabling XSG on more projects in #33524.

Metadata

Metadata

Labels

s/triagedIssue has been reviewed

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions