Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] (Re)Setting the ItemsSource of a CarouselView causes it to ignore the ItemsLayout #13038

Open
CMehlstaeubler opened this issue Dec 3, 2020 · 0 comments
Projects

Comments

@CMehlstaeubler
Copy link

CMehlstaeubler commented Dec 3, 2020

Description

My application uses the CarouselView as a main feature to show a series of opportunities to a user. The user needs to complete his user profile to a minimum degree in order to see these opportunities. Using the ItemTemplate property, I am using DataTemplateSelector to return a layout based on if the profile is completed or not. If the user does complete his profile (thereby allowing him to see the opportunities) the CarouselView does not automatically call the DataTemplateSelector again when the view is switched back to the page containing the CarouselView.

The workaround I have found to make this work is unsetting the ItemsSource and resetting it during the OnAppearing(). The code looks like this:

var tmp = OpportunityCarousel.ItemsSource;
OpportunityCarousel.ItemsSource = null;
OpportunityCarousel.ItemsSource = tmp;

This works fine on iOS, however on Android it causes the CarouselView to ignore the ItemsLayout, causing the Cards to scroll vertically, not horizontally as defined.

I have, of course, tried setting the ItemsLayout again during and after the snippet above, to no avail.

Steps to Reproduce

  1. Use a ContentPage within a TabbedPage, and within that ContentPage create a CarouselView which selects a template using a DataTemplateSelector
  2. Switch to another page in the TabbedPage, and update data which should cause the DataTemplateSelector to return a different DataTemplate
  3. (a) With the code above (on Android): The CarouselView scrolls vertically
  4. (b) Without the code above (on Android): The CarouselView scrolls horizontally, but does not update the DataTemplate to reflect the change

Expected Behavior

The CarouselView should keep using the ItemsLayout defined in the XAML/Code Behind.

I understand that the behaviour of the DataTemplateSelector is as expected (OnAppearing doesn't mean everything is redrawn), however changing the ItemsSource (which does cause the element to be redrawn) shouldn't cause the CarouselView to ignore the ItemsLayout property

Actual Behavior

When resetting the ItemsSource, the ItemsLayout is ignored

Basic Information

  • Version with issue: 4.8.0.1687+400-sha.91b883e6e-azdo.4215880 (Xamarin Forms)
  • Last known good version: Unknown (not tested previously)
  • Platform Target Frameworks:
    • Android: 10
  • Android Support Library / AndroidX Version: AndroidX
  • Affected Devices: Android Simulator, real Devices

Environment

Microsoft Visual Studio Community 2019
Version 16.4.2
VisualStudio.16.Release/16.4.2+29613.14
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools

ASP.NET and Web Tools 2019   16.4.457.38025
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   16.4.457.38025
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.4.457.38025
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.4.1000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   16.4.457.38025
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.4.1000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   3.4.1-beta4-19610-02+c4e5d138903b899477649a17f197abd2bcb22f9e
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

JetBrains ReSharper 2020.2.4   Build 202.0.20200925.65451
JetBrains ReSharper package for Microsoft Visual Studio. For more information about ReSharper, visit http://www.jetbrains.com/resharper. Copyright © 2020 JetBrains, Inc.

Microsoft Azure HDInsight Azure Node   2.4.1000.0
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.4.1000.0
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   16.0
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.4.1000.0
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.21016.1

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.0.87+gbb515bf382
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio   16.5.24 (1fafd7e)
Support for debugging Mono processes with Visual Studio.

Node.js Tools   1.5.11023.1 Commit Hash:579896f0984848d17d080c8a1c3ddff98d5ba96f
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   5.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.61912.09160
Microsoft SQL Server Data Tools

SyncfusionXamarinMenu Extension   1.0
SyncfusionXamarinMenu Visual Studio Extension Detailed Info

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   16.0.11031.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.4.1-beta4-19610-02+c4e5d138903b899477649a17f197abd2bcb22f9e
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6   16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview)   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes   1.0
Visual Studio Tools for Kubernetes

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Foo   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.4.000.307 (d16-4@e031886)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.4.0.464 (remotes/origin/d16-4@4abf337c3)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.4.25 (579ee62)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   10.1.1.0 (d16-4/f2c9364)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: bef1e63
    Java.Interop: xamarin/java.interop/d16-4@c4e569f
    ProGuard: xamarin/proguard/master@905836d
    SQLite: xamarin/sqlite/3.28.0@46204c4
    Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b


Xamarin.iOS and Xamarin.Mac SDK   13.8.3.0 (0d8fe21)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Screenshots

With the Snippet above in the OnAppearing method

Screenshot_1607005893

Without the Snippet above in the OnAppearing method

Screenshot_1607005971

The relevant code section (ItemsLayout) defining the CarouselView in XAML

image

Reproduction Link

The source code contains code that should not be shared publicly; I am willing to provide the relevant sections if needed.

@CMehlstaeubler CMehlstaeubler added s/unverified New report that has yet to be verified t/bug 🐛 labels Dec 3, 2020
@StephaneDelcroix StephaneDelcroix removed the s/unverified New report that has yet to be verified label Dec 3, 2020
@StephaneDelcroix StephaneDelcroix added this to New in Triage via automation Dec 3, 2020
@StephaneDelcroix StephaneDelcroix moved this from New to Ready For Work in Triage Dec 3, 2020
@Redth Redth moved this from Ready For Work to Needs Estimate in Triage Dec 15, 2020
@rmarinho rmarinho removed their assignment Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Needs Estimate
Development

No branches or pull requests

3 participants