Last active
December 18, 2015 12:11
-
-
Save kimsk/5572962 to your computer and use it in GitHub Desktop.
Windows 8 Splash screen sample, ใส่ dummy ProgressRing บน TextBlock จำลองการโหลด
1. หยุดไป 5 วินาทีให้เหมือนว่าโหลดอะไรบางอย่าง
2. ผมจำลองการโหลดข้อมูลนานๆ (คล้ายๆการ Thread.Sleep() บน .NET) เมื่อเสร็จแล้วเราก็ให้ไปโหลด MainPage โดยใช้ CoreDispatcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackPanel Grid.Row="1" HorizontalAlignment="Center"> | |
<ProgressRing Name="loadingSomething" IsActive="True" /> | |
<TextBlock Style="{StaticResource BasicTextStyle}" TextWrapping="Wrap" TextAlignment="Center" Padding="5" HorizontalAlignment="Center"> | |
The splash screen was dismissed and the image above was positioned using the splash screen API. | |
</TextBlock> | |
<Button x:Name="LearnMoreButton" Content="Learn More" HorizontalAlignment="Center" /> | |
</StackPanel> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include code to be executed when the system has transitioned from the splash screen to the extended splash screen (application's first view). | |
void DismissedEventHandler(SplashScreen sender, object e) | |
{ | |
dismissed = true; | |
// Navigate away from the app's extended splash screen after completing setup operations here... | |
// This sample navigates away from the extended splash screen when the "Learn More" button is clicked. | |
// Need dispatcher to inject code to UI thread | |
var dispatcher = rootFrame.Dispatcher; | |
// start loading | |
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
loadingSomething.IsActive = true; | |
}); | |
// load something for 5 seconds | |
new System.Threading.ManualResetEvent(false).WaitOne(5000); | |
// load end and navigate to MainPage | |
dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => | |
{ | |
rootFrame.Navigate(typeof(MainPage)); | |
Window.Current.Content = rootFrame; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment