I have form which has many tabs. Every tab has many controls textboxes, comboboxes, datagrids and e .t.c. I bind form to one data source in such way
this.DataContext=MyClassInstance
But with t开发者_如何转开发his way my form opening very slow. about one minute.
When I comment above code, form opens very quickly. All My controls I bound to the class properties in XAML. Please tell me the way to bind every tab when it's activated, or bind controls in background thread or any other idea which can help me to speed up my form.
Thanks in advance.
I think the problem lies in your class instance you are binding to.
When the xaml is bound to the class, all the getters of the bound properties are fired. If each getter accesses the database to get some data, this can take a while.
I think you should really review your design here, and think about asynchronously fetching your data.
I agree with Gerrie.
I'm suggesting the following: When you start your application, you automatically open one tab i guess. Load only that tab, don't care about the others. This should start your project much faster. The thing you do for the other tabs is load them when clicked for the first time. When the user for example is interested in tab 5, the only ones loading will be the initial tab at startup, and tab 5 when clicked by the user. all other tabs will not be loaded, which will decrease startup time.
Hope the idea is clear to you and will help your application.
I found why my form open so slow. I use about 20 XMLDataProvider object in form. and this providers were iteract with xml file. When I comment code below everything working fast. Thank everyone for help
//relatives_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RelativeList" };
//education_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_EducationList" };
//requalification_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RequalificationList" };
//jobHistory_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_JobHistoryList" };
//rank_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_RankList" };
//tradeUnion_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_TradeUnionList" };
//election_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_ElectionList" };
//judgeHistory_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_JudgeHistoryList" };
//tempWork_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_TempWorkList" };
//inquire_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_InquireList" };
//bulleten_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_BulletenList" };
//reprimand_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_ReprimandList" };
//certificate_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_CertificateList" };
//course_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_CourceList" };
//incentive_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_IncentiveList" };
//btrip_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_BtripList" };
//vacation_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_VacationList" };
//pass_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_PassList" };
//language_xdp = new XmlDataProvider() { Source = uri, XPath = "Config/ColumnsVisibility/Person_LanguageList" };
精彩评论