.Net maui carouselview на ошибке WindowsC#

Место общения программистов C#
Ответить
Anonymous
 .Net maui carouselview на ошибке Windows

Сообщение Anonymous »

Я создаю кроссплатформенное приложение .NET Maui, и я создал интропейс-адаптацию с помощью CarouseLView , связанной с моделью представления. The page works perfectly on Android, but on Windows, the behavior is broken:
  • The page randomly opens on a non-first carousel page, even though I set CurrentIndex = 0 in OnAppearing()
  • The left/right buttons glitch the carousel instead of moving it Правильно
  • Иногда элементы карусели перекрываются или анимация перехода кажется сломанной
  • , регистрация ) также не показывайте/скрыть правильно

Код: Выделить всё

IntroPage.xaml
:

Код: Выделить всё
























































< /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; }
}
}
< /code>
What I've tried:
[list]
[*]Setting CurrentIndex = 0
явно в onappearing ()
[*] Удаление indicatorView
[*] Отключение Isscolanimated и iSbounceEnabled
[*] Использование для привязки к привязке к правильному склонности через лога Dispatcher.dispatch () для задержки currentIndex = 0
[/list]
мой вопрос
Почему я могу исправить его, и ведут себя, начиная с «Windows против Android». Навигация? < /p>
Любая помощь будет очень оценена. Я использую: < /p>

.net Maui Последняя версия < /li>
Windows 11 < /li>
Visual Studio 2022 (последний) < /li>
< /ul>

Подробнее здесь: https://stackoverflow.com/questions/796 ... indows-bug
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»