首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Xamarin ProgressBar into overlay不可见

Xamarin ProgressBar into overlay不可见
EN

Stack Overflow用户
提问于 2016-07-13 15:38:06
回答 0查看 570关注 0票数 0

在Xamarin中,当我按下一个按钮时,我想用一个简单的ProgressBar显示一个覆盖图。

这是我的XAML布局

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="AbsoluteXamlDemo.SimpleOverlayPage">
<AbsoluteLayout>

<StackLayout AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">

  <Label FontSize="Medium" VerticalOptions="CenterAndExpand" HorizontalOptions="Center">This might be a page full of user-interface objects except that the only functional user-interface object on the page is a Button</Label>
  <Button Text="Run 5-Sec job" FontSize="Large" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" Clicked="OnButtonClicked"></Button>
  <Button Text="A DO-Nothing Btn" FontSize="Large" VerticalOptions="CenterAndExpand" HorizontalOptions="Center" ></Button>
  <Label FontSize="Medium" VerticalOptions="CenterAndExpand" HorizontalTextAlignment="Center" >This continues the page full of user-interface objects except that the only functional user-interface object on the page is the Button.</Label>

</StackLayout>

<ContentView x:Name="overlay" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" IsVisible="False" BackgroundColor="#C0808010" Padding="10,0">
  <ProgressBar x:Name="ProgressBar" VerticalOptions="Center"></ProgressBar>
</ContentView>
</AbsoluteLayout>

这是OnButtonClicked函数

代码语言:javascript
复制
        overlay.IsVisible = true;

        TimeSpan duration = TimeSpan.FromSeconds(5);
        DateTime startTime = DateTime.Now;

        Device.StartTimer(TimeSpan.FromSeconds(0.1), () =>
        {                
            double progress = (DateTime.Now - startTime).TotalMilliseconds / duration.TotalMilliseconds;
            ProgressBar.Progress = progress;
            bool continueTimer = progress < 1;
            if (!continueTimer)
            {
                // Hide overlay. 
                overlay.IsVisible = false;
            }
            return continueTimer;
        });

问题是,当我点击按钮时,覆盖显示出来了,但是ProgressBar却没有!为什么?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38345416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档