maui
maui copied to clipboard
Changing CarouselView Position has no effect until it is set >0 and back to 0 when loop is disabled
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
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
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.
Can confirm. Workaround is to indeed set Position on 1, then on 0 and then on 1 the first time you increment the position
Any update ? Thanks
any updates? i just wanted to report the same issue
any update ?
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...
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?
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Not repro on Android platform with sample project. Reproduction Repository
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
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.
Any update ?
It works properly on .net 8 RC2
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;
}
}
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.