Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Performance issues and usability improvements

$
0
0

Hi,

I need some suggestions, help to solve any problems. I have to create a view with a dynamic count of ContentPages. I created two ViewModels, one with a logic and a stop watch and a second one to control the dynamic pages. It looks like this:

CircleViewModel:

public class CircleViewModel: ViewModelBase {
    public ObservableCollection<Circle> Circles { get; set; }

    private string _timeText;

    public string TimeText { 
        get => _timeText; 
        set {
        _timeText = value; 
        OnPropertyChanged();
        }

    // Some ICommands and methods

    public async Task StartStopWatch() { ... }
}

MultiPageViewModel:

public class MultiPageViewModel : ViewModelBase {
public ObservableCollection<CircleViewModel> Pages { get; set; }

private CircleViewModel _currentPage;

public CircleViewModel CurrentPage { 
    get => _currentPage; 
    set {
         _currentPage = value;
        OnPropertyChanged();
    }

 // Some ICommands and methods
}

MultiPageView.xaml:

<ContentPage ...
   BindingContext="{Binding MultiPageViewModel, Source={StaticResource Locator}}">
    <Grid>
        <ListView ItemsSource="{Binding CurrentPage.Circles}"/>
        <Label Text="{Binding CurrentPage.Title}"/>
        <Button Text="{Binding CurrentPage.TimeText}" Command="{Binding CurrentPage.StartWatchCommand}"/>

        <userControls:VerticalTabView ItemsSource="{Binding MultiPageViewModel.Pages, Source={StaticResoruce Locator}}"
        MoreButtonCommand="{Binding MultiPageViewModel.MoreButtonCommand, Source={StaticResource Locator}}"/>
    </Grid>
</ContentPage>

VerticalTabView is a user control to change the current page. I do not like the usability, so I changed the ContentPage to CarouselPage. With UWP it works fine, with Android the scrolling starts to stutter, in the output of Visual Studio appears "The application may be doing too much work on its main thread." and crashes with an OutOfMemory Exception. The CarouselPage does not work with iOS currently.

How can I improve this? I am grateful for any advice. Thank you.


Viewing all articles
Browse latest Browse all 204402

Trending Articles