Windows phone 7 -- programmatically create the initial UI?
I want to create the UI in co开发者_运维技巧de when the app starts up. What would be the natural place for this code?
You would probably want to put it in the page constructor right after the InitializeComponent()
call. I don't see a need to do this since you have the XAML designer at hand anyway - it will eventually create a small performance overhead because you are building the page twice - once when it's loaded and the second time when you add additional components.
I am assuming your intention is to have a total control of the application resources in this manner. You get one entry point, where you can initialize a view, as well as the other operational classes, that make your application tick.
So my answer would be this:
In App() initialize an IoC right a way.
Then let default code, such as InitializeComponent()
do it's job. Remove InitializePhoneApplication()
and insert your view initialization logic there.
精彩评论