Если вам это нужно, вам следует создать источник данных виртуальной машины для создания зависимости в вашей первой виртуальной машине.
public class YourViewModelDataSource
{
private ViewModel viewModel;
private SecondViewModel secondViewModel;
public YourViewModelDataSource(ViewModel viewModel, SecondViewModel secondViewModel)
{
this.viewModel = viewModel;
this.secondViewModel = secondViewModel;
}
public void CreateDataSource()
{
this.secondViewModel.PropertyChanged += this.OnSecondViewModelPropertyChanged;
}
private void OnSecondViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
//As pointed in comments, you need to have the second property in your first ViewModel then do this.
case "SecondProperty":
this.viewModel.myProperty = this.secondViewModel.SecondProperty;
break;
}
}
}
Когда вы создаете свои виртуальные машины, используйте этот класс для создания зависимости.Каждый раз, когда SecondViewModel
SecondProperty изменяется, ViewModel
myProperty будет повышаться.Надеюсь, это понятно, дайте мне знать, если вам нужно что-то еще