MVVM pass/bind value form ViewModel to ViewModel of parent View without using constructor
Project detail
I’ve a shared core project(contains ViewModels) between WPF and Xamarin.Forms apps(each one contain it’s views and interface implementations)
It’s a .NetStandard class library using Prism.Core.
In this Project I’ve tow ViewModels for two views:
TabItem=TabItemViewModel, BrowserView=BrowserViewModel
public class TabItemViewModel : INotifyPropertyChanged
{
public string Url {get; set} // shortened for clarity
// …..
}
public class BrowserViewModel: INotifyPropertyChanged
{
public string Url {get; set} // shortened for clarity
// …..
}
How to pass the url between the two ViewModels??
The app is browser like with multiple tab instances.
I don’t want and I can’t use the viewmodel constructor like new viewmodel(url) for business logic considrations.
I’ve read suggestion to use dependency property,
but I can’t define it in the viewmodel as it requires
using System.Windows;
and the viewmodel only uses .netstandard and prism.core.
other suggestions to define dependancy property in the code behind xaml.cs
but I could not get it working.
I need to sync multiple properties not only url.
I need working sample code