【问题标题】:How to add ActivityIndicator to shell flyout如何将 ActivityIndi​​cator 添加到外壳弹出窗口
【发布时间】:2021-02-03 10:57:28
【问题描述】:

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

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

如何添加?

【问题讨论】:

    标签: c# xaml xamarin xamarin.forms.shell


    【解决方案1】:

    你可以使用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;
            }
    

    【讨论】:

    • 非常感谢。虽然方法有点不同,但我按照你的想法解决了问题。我对Strack Overflow不是很熟悉,不小心编辑了你的答案,请见谅
    • 没问题没关系 :)
    猜你喜欢
    • 2018-07-28
    • 1970-01-01
    • 2017-01-01
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 2015-04-12
    • 2021-04-28
    • 2019-11-18
    相关资源
    最近更新 更多