maui icon indicating copy to clipboard operation
maui copied to clipboard

Changing CarouselView Position has no effect until it is set >0 and back to 0 when loop is disabled

Open KPHIBYE opened this issue 2 years ago • 2 comments

Description

When changing the Position property of a CarouselView with Loop disabled in code and it has not already been changed through swiping, the CarouselView will not change its displayed item until Position was set to a value >0 and back to 0. After this, the behavior is as expected. If Loop is enabled, the behavior is as expected on Android.

I am unsure if Windows is affected since the CarouselView behaves very differently compared to Android, as #7180 shows.

Steps to Reproduce

Reproduction Repository

OR

Create a CarouselView with Loop disabled and try to change the displayed item by changing the position property exclusively in code

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 5 and up

Did you find any workaround?

Yes, setting Loop to true, or setting Position to something other than zero and back

Relevant log output

No response

KPHIBYE avatar Aug 29 '22 15:08 KPHIBYE

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 30 '22 18:08 ghost

Can confirm. Workaround is to indeed set Position on 1, then on 0 and then on 1 the first time you increment the position

eddie010 avatar Oct 28 '22 14:10 eddie010

Any update ? Thanks

tranb3r avatar Nov 29 '22 12:11 tranb3r

any updates? i just wanted to report the same issue

DeepWorksStudios avatar Mar 16 '23 16:03 DeepWorksStudios

any update ?

SarthakB26 avatar Apr 24 '23 15:04 SarthakB26

It's just ridiculous.. its like reporting a bug does not make any difference by now since they don't fix most of the reported bugs or they just really to slow...

DeepWorksStudios avatar Apr 24 '23 15:04 DeepWorksStudios

He's not wrong, why are these still open? Can you advise what the official solution is here, do we simply move to .net 8 previews? Is .net 8 previews better than current state of production .net 7?

jadenrogers avatar May 30 '23 03:05 jadenrogers

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Not repro on Android platform with sample project. Reproduction Repository

homeyf avatar Jun 06 '23 09:06 homeyf

He's not wrong, why are these still open? Can you advise what the official solution is here, do we simply move to .net 8 previews? Is .net 8 previews better than current state of production .net 7?

Unfortunately this is not really an option, I tried to switch to .net 8 preview but it made the situation worse in terms of stability and bugs. I can only advise you to stay with .net 7 until .net 8 is released for public use

DeepWorksStudios avatar Jun 09 '23 02:06 DeepWorksStudios

Testing with net8 preview6 I confirmed this behavior still exists. I also confirmed that MyCarousel.ScrollTo(1); works immediately. Try this for now.

Also confirmed this method works on .NET 7.

davidortinau avatar Jul 20 '23 19:07 davidortinau

Any update ?

BeepBeepBopBop avatar Sep 15 '23 17:09 BeepBeepBopBop

It works properly on .net 8 RC2

standamikes avatar Oct 22 '23 18:10 standamikes

You can just create this kinda workaround new carouselview control with Position property, here is an example

 public class CustomCarouselView : CarouselView
 {
     public new static readonly BindableProperty PositionProperty =
         BindableProperty.Create(nameof(Position), typeof(int), typeof(CustomCarouselView), propertyChanged: OnPositionPropertyChanged);

     private static void OnPositionPropertyChanged(BindableObject bindable, object oldValue, object newValue)
     {
         var carouselView = bindable as CustomCarouselView;
             if (carouselView.viewModel is ViewModels.MyLibraryPageViewModel myLibraryVm)
             {
             carouselView.ScrollTo(myLibraryVm.CurrentTabIndex);
             }
     }

     public new int Position
     {
         get => (int)GetValue(PositionProperty);
         set => SetValue(PositionProperty, value);
     }

     private BaseVm viewModel;

     protected override void OnBindingContextChanged()
     {
         base.OnBindingContextChanged();

         viewModel = BindingContext as BaseVm;
     }
 }

beglaryan-alen avatar Nov 04 '23 11:11 beglaryan-alen

Hi @KPHIBYE. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.