简体   繁体   中英

The wait mark animation does not disappear on Xamarin.Forms

I am developing with Xamarin.

When I scroll a CollectionView, the wait mark animation does not disappear even after the scrolling is finished. How can I remove it?

        <StackLayout Spacing="20" Padding="15" >
            <RefreshView x:DataType="local:ItemDetailViewModel"
                 IsRefreshing="{Binding IsBusy, Mode=TwoWay}">
                <CollectionView x:Name="ItemsListView"
                 ItemsSource="{Binding EventItems}" SelectionMode="None">

                 <!--  ...template...  -->

                </CollectionView>
            </RefreshView>

        </StackLayout>

When you finish the task inside the refresh command you need set to IsBusy to False.

<RefreshView IsRefreshing="{Binding IsBusy}"
             Command="{Binding RefreshCommand}">

</RefreshView>
public ICommand RefreshCommand { get; }

public ItemsViewModel()
{
    Title = "Browse";
    Items = new ObservableCollection();
    RefreshCommand = new Command(ExecuteRefreshCommand);
}

bool _isBusy;

public bool IsBusy
{
    get => _isBusy;
    set
    {
        _isBusy = value;
        OnPropertyChanged(nameof(IsBusy));
    }
}

void ExecuteRefreshCommand()
{
    // DO your task and then
    // Stop refreshing
    IsBusy = false;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM