我想将SecondViewModel SecondProperty 的值传递给ViewModel myProperty ,并在TextBlock上显示该值。我需要在 SecondViewModel 中进行编码。 ViewModels有两个不同的视图。
感谢Advance的帮助。
查看:
<TextBlock Text="{Binding Path=myProperty}"/>
ViewModel:
private int _myProperty;
public int myProperty
{
get { return _myProperty; }
set { _myProperty= value; OnPropertyChanged("myProperty");}
}
SecondViewModel:
public SecondViewModel()
{
Command = new RelayCommand(Method);
}
public void Method()
{
// need coding to be done here
// ViewModel vm = new ViewModel();
// vm.myProperty= this.SecondProperty
// I tried this code and many more but its not working for me
}
public ICommand Command { get; set; }
private int _secondProperty;
public int SecondProperty
{
get { return _secondProperty; }
set { _secondProperty= value; OnPropertyChanged("SecondProperty");}
}