Activity indicator dosent show

Eduardo Gomez 3,431 Reputation points
2023-11-29T02:15:00.7066667+00:00

I have a register popup

   <sfPopup:SfPopup
       x:Name="sfPopup"
       AnimationMode="Zoom"
       HeaderTitle="Register"
       HeightRequest="300"
       IsOpen="{Binding IsPopOpen}"
       ShowCloseButton="True"
       StaysOpen="True">
       <sfPopup:SfPopup.ContentTemplate>
           <DataTemplate>
               <Grid
                   Margin="5"
                   RowDefinitions="80,80,40">
                   <inputLayout:SfTextInputLayout
                       ContainerBackground="White"
                       ContainerType="Outlined"
                       Hint="Email"
                       IsHintAlwaysFloated="True"
                       IsVisible="{Binding IsVisible}"
                       OutlineCornerRadius="8">
                       <Entry Text="{Binding Student.Email}" />
                   </inputLayout:SfTextInputLayout>

                   <inputLayout:SfTextInputLayout
                       Grid.Row="1"
                       ContainerBackground="White"
                       ContainerType="Outlined"
                       Hint="Password"
                       IsHintAlwaysFloated="True"
                       IsVisible="{Binding IsVisible}"
                       OutlineCornerRadius="8">
                       <Entry Text="{Binding Student.PasswordHash}" />
                   </inputLayout:SfTextInputLayout>

                   <ActivityIndicator
                       Grid.RowSpan="3"
                       IsRunning="{Binding IsBusy}"
                       HeightRequest="100"
                       WidthRequest="100"
                       Color="#422777" />

                   <Button
                       Grid.Row="3"
                       Command="{Binding RegisterCommand}"
                       CornerRadius="8"
                       IsVisible="{Binding IsVisible}"
                       Text="Register" />
               </Grid>
           </DataTemplate>
       </sfPopup:SfPopup.ContentTemplate>
   </sfPopup:SfPopup>


and I have my view model

[ObservableProperty]
bool isVisible = true;

[ObservableProperty]
bool isPopOpen;

[ObservableProperty]
Student student = new();

[RelayCommand]
void OpenPopUp() {
    IsPopOpen = true;
}

[RelayCommand]
Task Login() {
    return Task.FromResult(0);
}

[RelayCommand]
async Task Register() {
    IsBusy = true;
    IsVisible = false;
    IsPopOpen = false;
    Student.Id = Student.GenerateRandomNumberString();
    Student.Email = Student.Email;
    Student.SetPassword(Student.PasswordHash);

    var key = await dataService.AddAsync("Users", Student);
    if (key is not null) {
        IsBusy = false;
        IsVisible = true;
    }

the problem is that when I start registering I dont see the activity indicator

Demo: https://github.com/eduardoagr/DemyAI

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,807 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 46,821 Reputation points Microsoft Vendor
    2023-11-30T03:07:34.7666667+00:00

    Hello,

    After testing your sample code, the ActivityIndicator appears as expected.

    the problem is that when I start registering I dont see the activity indicator

    This happens when the registration check completes quickly. If you add a delayed operation, or test it while the network is disconnected, you'll see the ActivityIndicator.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.