- Страница случайно открывается на не первой странице каруселей , даже если я установил CurrentIndex = 0 in на первой () . /> Левая/правая кнопки сгруппировать карусель вместо правильного перемещения., регистрация ) также не показывайте/скрыть правильно.
Код: Выделить всё
LoginЧто я попробовал:Код: Выделить всё
< /code> intropage.xaml.cs namespace restaurant; public partial class IntroPage : ContentPage { public IntroPage() { InitializeComponent(); } protected override void OnAppearing() { base.OnAppearing(); if (BindingContext is ViewModels.IntroViewModel vm) { vm.CurrentIndex = 0; } } } < /code> introviewmodel.cs using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Input; using Microsoft.Maui.Controls; namespace restaurant.ViewModels { internal class IntroViewModel : INotifyPropertyChanged { public ObservableCollection Pages { get; } private int _currentIndex; public int CurrentIndex { get => _currentIndex; set { if (_currentIndex != value) { _currentIndex = value; OnPropertyChanged(); OnPropertyChanged(nameof(IsFirstPage)); OnPropertyChanged(nameof(IsNotFirstPage)); OnPropertyChanged(nameof(IsLastPage)); OnPropertyChanged(nameof(IsNotLastPage)); OnPropertyChanged(nameof(CurrentItem)); } } } public IntroPageModel CurrentItem => (CurrentIndex >= 0 && CurrentIndex < Pages.Count) ? Pages[CurrentIndex] : null; public bool IsFirstPage => CurrentIndex == 0; public bool IsNotFirstPage => !IsFirstPage; public bool IsLastPage => CurrentIndex == Pages.Count - 1; public bool IsNotLastPage => !IsLastPage; public ICommand NextCommand { get; } public ICommand PreviousCommand { get; } public ICommand LoginCommand { get; } public ICommand SignUpCommand { get; } public IntroViewModel() { Pages = new ObservableCollection { new IntroPageModel { Title = "Welcome!", Description = "Manage your restaurant with SIMR Admin.", Image = "intro1.png" }, new IntroPageModel { Title = "Track Orders", Description = "Monitor food orders and ingredients.", Image = "intro2.png" }, new IntroPageModel { Title = "Analyze Statistics", Description = "Gain insights on your restaurant's performance.", Image = "intro3.png" }, new IntroPageModel { Title = "Get Started", Description = "Login or sign up to begin using SIMR Admin.", Image = "intro4.png" } }; CurrentIndex = 0; NextCommand = new Command(() => { if (IsNotLastPage) CurrentIndex++; }); PreviousCommand = new Command(() => { if (IsNotFirstPage) CurrentIndex--; }); LoginCommand = new Command(async () => await Application.Current.MainPage.Navigation.PushAsync(new LoginPage())); SignUpCommand = new Command(async () => await Application.Current.MainPage.Navigation.PushAsync(new RegisterPage())); } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string name = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } internal class IntroPageModel { public string Title { get; set; } public string Description { get; set; } public string Image { get; set; } } }
Настройка CurrentIndex = 0 явно в OnapeAring () . - removing indicatorView
removing indicatorView - removing indicatorview /> Отключение Isscrollanimated и iSbounceenabled .
- Проверка привязки, которые правильно запускаются с помощью журналов отладки. 0 .
Почему Carouselview ведут себя по -разному в Windows vs Android в .net Maui, и как я могу исправить глики, и всегда будет начинать на первой странице с правильной страницей? ценится. Я использую: < /p>
< /li>
Windows 11 < /p>
< /li>
Visual Studio 2022 (последнее) < /p>
< /li> < /> >
Подробнее здесь: https://stackoverflow.com/questions/796 ... indows-bug