I am working on an application that started as WinForm, but now it uses WPF windows with a user interface. The interaction works fine, but when the WPF windows are displayed for the first time, it takes quite a while (about 1-3 seconds) to view them. So long that some are surprised if the application crashes (until the content is shown). The second time, when identical windows are called, they quickly appear. I need them to get up quickly for the first time.
I use styles and control patterns that are in XAML in the resource folder. In XAML for WPF windows, I then combine them into a Windows resource dictionary. The build action for those (in VS 2010) must be set to Resource. I prefer to store them in separate files for ease of maintenance. As far as I understand, if the assembly action was a βpageβ, XAML would be precompiled and should load faster, but if I installed it on the page, I could not combine them into a resource dictionary. Is there any way around this?
I am new to this part of WPF, and so far my internet search has not been successful.
To be clear: I'm not saying that WPF controls are built into WinForms. I am talking about completely separate WPF windows that are generated from a WinForm context.
Is there a way to precompile the entire application, or at least all XAML (all this is static, without dynamic XAML)?
Thanks in advance!
Edit: user interfaces are not heavy. Those in question have 5 to 20 buttons and regular containers (mostly a grid with 1 or 2 stack panels).
Update: I tried to precompile using "NGEN install appname" - it does not affect the loading of the WPF window.
I have included all resources and templates in window.xaml - no effect. (window.xaml precompiled)
I found this interesting article about pre-jitting application downloads here:
http://www.codeproject.com/KB/dotnet/pre_JIT.aspx (I used the improvement suggested by "ittay ophir")
- again: no effect on loading WPF window ...
The load time simply does not change at the first load, but they are significantly reduced at all consecutive loads (loads of 20 ms or less).
What's going on here?