Reputation: 45981
I'm developing a Windows 8.1 app with C# and .NET Framework 4.5.
I have a Page with an image as background:
</Page.Resources>
<Grid>
<Grid.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="ms-appx:///Assets/Backgrounds/Clase.png"/>
</Grid.Background>
But, I see that first appears the page and after that appears the image (it gets less than a second to load, but I can see perfectly a black background and then the image).
This is how I navigate to that page:
if (Frame != null)
Frame.Navigate(typeof(QuizPage));
And I set the image as Content and Copy always.
How can avoid this problem? Is there anyway to preload that image?
Upvotes: 1
Views: 791
Reputation: 31724
I don't know for sure, but I have a feeling that the Navigate()
call might actually be waiting for a bit so smaller images show immediately, but to get an immediate navigation and make apps responsive - it quickly times out and navigates even when images are not loaded.
The AlternativeFrame
and AlternativePage
controls in WinRT XAML Toolkit are swap-in replacements for Frame
/Page
ones that come with the framework. Their API surface is fairly similar, but they have some additions. Among others - the ShouldWaitForImagesToLoad
property that makes them wait for all images to load on the page being navigated to. Also there is a Preload()
method that allows to preload the next page or pages so that when you call Navigate()
- the next page with its images has already loaded in the background and can be shown immediately.
The page transition animations are an added bonus.
Upvotes: 1