WPF page background loading...how to?
I have a WPF Window with tab control. Every tabitem of tab control have a frame with PAGE as content...like this:
<TabItem Name="Tab01">
<Frame Name="Tab01Frame" />
</TabItem>
MyPage Tab01Page = New MyPage()
Tab01Frame.Navigate(Tab01Page)
Now, I have this problem. Every page for tabitem is loading on window contructor and thi开发者_C百科s cause a performance bottleneck for window. It takes some seconds to show.
Is there a way to load pages on background process?
To start, move the initialization code to the Loaded event (not in the constructor). This will make the UI appear more responsive. Also, use the Dispatcher object to background the task.
private delegate void DelegateTypeYouDeclare();
this.Dispatcher.BeginInvoke(new DelegateTypeYouDeclare(MethodToCall), null);
Those are just first steps. For a better example see the following MSDN article: http://msdn.microsoft.com/en-us/magazine/cc163328.aspx
精彩评论