如何将 ActivityIndi​​cator 添加到 shell 弹出窗口

How to add ActivityIndicator to shell flyout

我在 shell 的 FlyoutFooter 中添加了一个注销按钮。点击后需要一定的等待时间才能连接到服务器,所以我需要在flyout中添加一个ActivityIndicator

  <Shell.FlyoutFooter>
        <Grid>
            <Button Text="Logout"
                    Clicked="Button_Clicked"/>
        </Grid>
    </Shell.FlyoutFooter>

如何添加到那里?

您可以使用 FlyoutContent 属性:

   <Shell.FlyoutFooter>
        <Grid>
            <Button Text="Logout"
                    Clicked="Button_Clicked"/>
        </Grid>
    </Shell.FlyoutFooter>
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var grid = new Grid();
            grid.Children.Add(new ActivityIndicator()
            {
                IsRunning = true,
                VerticalOptions = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            });

            Current.FlyoutContent = grid;
            await Task.Delay(5000);
            FlyoutContent = null;
        }