Closed ghost1372 closed 5 years ago
Hi Mahdi, I watched the video. Great to see MVVMC used in serious apps!
Let's see that I understand the problem. If Usercontrol 3 was loaded in tab1, and you move to tab2, and then you move back to tab1. So you want to have Usercontrol3 in the same state it was before. So you want to prevent Usercontrol3 from unloading and then reloading again. Is this the case?
If this is the case, then the navigation service doesn't support this. Each navigation will unload the previous View and load the new View. There are several ways I can think of to solve this for you.
1) It's possible to develop a NavigateWithViewModel(viewModel) type of method, where you will keep the previous instance of the ViewModel in memory 2) You can save the state of Usercontrol 3 in an object, and then pass that object as the NavigationParameter. Then, in the Initialize() method of the ViewModel, change your View to the previous state. 3) If you want each Tab to have the content always loaded, then it's not navigation. It's just a regular tab view. So maybe this specific part of the program shouldn't use MVVMC.
Do you think these will work for you?
yes this is what i want. I am not familiar with mvvm, but I'm trying to do the things you said (I think I can implement 2 & 3 ) You can also see my project here Thanks for the help
Great, tell me if you encounter any problems or need any help. I'm not closing this issue for now.
Also, I really recommend using mvvm with WPF.
Hi, I have a tab control when I load my Usercontrols on tab 1 (for example usercontrol 3) Then I change the tab When I go back to the previous tab, Usercontrol 3 was removed and Initial Usercontrol reloaded. In this video I tried to solve this problem with a trick But there was another problem please watch this video xx.zip