2016-04-12 25 views
0

Web görüntüleme özelliğini kullanarak bir web uygulamasına ev sahipliği yapan bir Windows Evrensel Uygulaması geliştiriyorum. adımları gibi takip edilir. Boş bir evrensel pencere uygulaması oluşturmaGezinme Evrensel Windows platformunda

  1. Bir Splash ekranı oluşturma. Başlangıç ​​sayfası olarak açılış ekranını ayarlayın. Tüm aktivitelerden sonra numarasına geçmek istiyorum. Bir web görünümü kontrolüne sahip olan Ana sayfada gezin.
  2. Web görünümünün kaynağı olarak bir "http: www.google.come" url örneği ayarlama. Her şey iyi çalışıyor ama ana sayfa zaman alıyor, ben yüklenene kadar aynı açılış ekranını görmek istiyorum.
  3. Navigasyon için kod kullanıyorum this.Frame.Navigate (typeof (MainPage)); tamamen uygulamayı yükleyen til

tam kaynak kodu

public sealed partial class ExtentedSpash : Page 
{ 
    public ProgressMessage Progress; 
    public ExtentedSpash() 
    { 
     this.InitializeComponent(); 
     Progress = ProgressMessage.GetMessage(); 
     DataContext = Progress; 
     Window.Current.Activate(); 
     Loaded += Splash_Loaded; 
    } 

    private async void Splash_Loaded(object sender, RoutedEventArgs e) 
    { 
     await Initialize(); 
     Window.Current.Activate(); 

     await ClearBrowserCache(); 
     Window.Current.Activate(); 

     //Task.WaitAll(TaskList.ToArray()); 
     await StartApplication(); 
    } 


    public async Task Initialize() 
    { 
     Progress.ActionMessage = "Initialize the controls"; 
     await Task.Delay(TimeSpan.FromSeconds(10)); 
    } 
    public async Task ClearBrowserCache() 
    { 
     Progress.ActionMessage = "Clear Browser Cache"; 
     await Task.Delay(TimeSpan.FromSeconds(10)); 
    } 

    public async Task StartApplication() 
    { 
     Progress.ActionMessage = "Loading"; 
     await Task.Delay(TimeSpan.FromSeconds(10)); 
     this.Frame.Navigate(typeof(MainPage)); 
    } 

    private void btnMain_Click(object sender, RoutedEventArgs e) 
    { 

    } 
} 
public class ProgressMessage : INotifyPropertyChanged 
{ 
    private string statusMessage; 

    public string StatusMessage 
    { 
     get { return statusMessage; } 

     set 
     { 
      statusMessage = value; 
      RaiseProperChanged(); 
     } 
    } 

    private string actionMessage; 

    public string ActionMessage 
    { 
     get { return actionMessage; } 

     set 
     { 
      actionMessage = value; 
      RaiseProperChanged(); 
     } 
    } 
    private bool showProgress; 

    public bool ShowProgress 
    { 
     get { return showProgress; } 
     set { showProgress = value; 
      RaiseProperChanged(); 
     } 
    } 


    public static ProgressMessage GetMessage() 
    { 

     var msg = new ProgressMessage() 
     { 
      StatusMessage = "Initializing Application", 
      ActionMessage = "One moment please...", 
      showProgress = true 
     }; 

     return msg; 
    } 

    public event PropertyChangedEventHandler PropertyChanged; 

    private void RaiseProperChanged(
     [CallerMemberName] string caller = "") 
    { 

     if (PropertyChanged != null) 
     { 
      PropertyChanged(this, new PropertyChangedEventArgs(caller)); 
     } 

    } 


} 

} "Yükleme Üzerine"

istediğim mesaj göstermelidir. Daha önce tartıştığımız gibi, sadece yüklendiği tam değildir kaynak olduğunda WebView kapsamak istiyorsanız

+0

'MainPage' öğesine yönlendirildikten sonra bir mesaj gösterdiğinizde bu tamam mı? Webview kaynağı tamamen yükleninceye kadar kaybolur mu? WebView' kaynağının tam olarak yüklenmesinden önce boş bir alan gösterecek, bu alanı kapsamak istiyorsunuz? –

+0

Teşekkürler Grace, böyle bir şey istiyorum –

cevap

1

, bunu şöyle yapabilirsiniz:

<Page.Resources> 
    <Storyboard x:Key="MyTextSTD" x:Name="MyTextSTD" RepeatBehavior="Forever"> 
     <ColorAnimationUsingKeyFrames Storyboard.TargetName="tbbrush" Storyboard.TargetProperty="Color" Duration="0:0:10"> 
      <DiscreteColorKeyFrame KeyTime="0:0:0" Value="Red" /> 
      <LinearColorKeyFrame KeyTime="0:0:5" Value="Blue" /> 
      <LinearColorKeyFrame KeyTime="0:0:10" Value="Purple" /> 
     </ColorAnimationUsingKeyFrames> 
    </Storyboard> 
</Page.Resources> 

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <WebView Source="https://msdn.microsoft.com/library/windows/apps/xaml/mt244352.aspx" NavigationCompleted="WebView_NavigationCompleted"> 
    </WebView> 
    <Grid x:Name="loadingGrid" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="Visible"> 
     <TextBlock Text="On Loading..." FontSize="50" VerticalAlignment="Center" HorizontalAlignment="Center"> 
      <TextBlock.Foreground> 
       <SolidColorBrush x:Name="tbbrush" /> 
      </TextBlock.Foreground> 
     </TextBlock> 
    </Grid> 
</Grid> 

Ve kod arkasında:

public MainPage() 
{ 
    this.InitializeComponent(); 
    MyTextSTD.Begin(); 
} 

private void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args) 
{ 
    loadingGrid.Visibility = Visibility.Collapsed; 
} 

Burada oldukça basit, mesajı göstermek için TextBlock ve bazı renkli animasyonları kullanıyorum. Ve bu mesaj WebView kaynağı tamamen yüklendiğinde kaybolacaktır.

İlgili konular