0
votes

I have MasterDetailPage with burger button. For this I make this navigation path:

var navigationStack = new Uri("https://Necessary/" + $"{nameof(ProfilePage)}/{nameof(NavigationBarPage)}/{nameof(DetailPage)}", UriKind.Absolute);  
await _navigationService.NavigateAsync(navigationStack, parameters, animated: false);

ProfilePage - MasterDetailPage, NavigationBarPage - NavigationPage

But I realized that because of it, viewmodels calls two times, one for ProfilePage - that causes to call DetailPageViewModel and Master.. and all childrens of Detail because it is Tabbed Page. And then when path comes to DetailPage, it calls its childrens one more time.
It is bad behavior for me. Is I am doing something wrong? And how I can avoid it with same look of my page?

If it will be {nameof(ProfilePage)}/{nameof(NavigationBarPage)} it will not look same like I want, because Toolbar will hide a part of MasterPage.

1
You need to clarify the issue. Actually, what exactly is the issue? What does "causes to call DetailPageViewModel" or "it calls its children"? Can you explain a little more clearly? - user5420778
Look at navigation path that I have. It has ProfilePage, that is MasterDetailPage, and as detail of it is DetailPage. So, because it is going first, DetailPage and its viewmodel runs here, and then, in the end of path it has DetailPage, that viewmodel was runned in ProfilePage, is running one more time. But I don't want to have it two times. I understand that it is right behavior, but how I can avoid it but with the same result on display? I didn't find another solution. - Yura Babiy
What do you mean by "run". A VM is only created once with each Page. - user5420778
I mean that it creates and executes code, that is in it. VM creates when page creates, so because in one Navigation path I have two pages, that are same (detail page of ProfilePage - that is DetailPage, and DetailPage itself), so it creates two times. - Yura Babiy

1 Answers

0
votes

Based on your comments, I can only assume that when you defined your MasterDetailPage, you are also defining the DetailPage too. Do not do this. Simply have Your MasterDetailPage, with the Master property set and do not set the Detail property. The Detail property will be set automatically when you navigate using your deep link path.