You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
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
Use a ContentPage within a TabbedPage, and within that ContentPage create a CarouselView which selects a template using a DataTemplateSelector
Switch to another page in the TabbedPage, and update data which should cause the DataTemplateSelector to return a different DataTemplate
(a) With the code above (on Android): The CarouselView scrolls vertically
(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
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
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
Environment
Screenshots
With the Snippet above in the OnAppearing method
Without the Snippet above in the OnAppearing method
The relevant code section (ItemsLayout) defining the CarouselView in XAML
Reproduction Link
The source code contains code that should not be shared publicly; I am willing to provide the relevant sections if needed.
The text was updated successfully, but these errors were encountered: