2016-07-13 6 views
0

ボタンを押したとき簡単なProgressBarでオーバーレイを表示したい。ボタンを押したときにXamarin ProgressBarオーバーレイが表示されない

この問題は、私はボタンをクリックすると、オーバーレイが表示されていることですが、プログレス私のXAMLレイアウト

<?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される機能

 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; 
     }); 

ですない!どうして?

答えて

0

私は解決策を見つけました。単純にXamarin.FormsをNugetパッケージに更新しました。

関連する問題