I accidentally discovered this little trick of WPF, which is quite interesting.
I added an image to the project.
Wpf-1.JPG(10.73 K) 17:04:47
Then, set the image generation operation to splashscreen in the image attributes.
Wpf-2.JPG(13.51 K) 17:04:47
After F5 starts the program, you will find that a 0.5 second animation will appear before your main program starts. Of course, this is the default one. You can control it through the program.
Bo you: how to control it?
Debuglzq: first, let's see what happened in this process. Use reflector to decompile the PE file as follows:
From the above il code, we can intuitively see that, in fact, it first instantiates a splashscreen and then calls its show method.
If so, of course we can also write code to achieve, the msdn document on the description of the splashscreen address: http://msdn.microsoft.com/zh-tw/library/cc647682.aspx access related methods, as follows:
We can achieve this by referring to the following implementation:
First, let's change the image generation operation to "embedded resource"
Then the code is implemented. debuglzq provides the complete code as follows:
/// <Summary> /// app. interaction logic of XAML // </Summary> Public partial class app: Application {protected override void onstartup (startupeventargs e) {splashscreen S = new splashscreen ("debuglzq. jpg "); S. show (false); S. close (New timespan (0, 0, 10); base. onstartup (e );}}
Note (from msdn, please refer to the msdn document: http://msdn.microsoft.com/zh-tw/library/cc647682.aspx ):
1. The splashscreen type cannot be used in some trust cases.
2. The splashscreen type cannot be used in the XAML compiler Application Program (xbap) because these applications use different robot motion frames.