0

I have a one ViewModel like this:

public class TaskTrayViewModel<T> : ViewModelBase where T : IBlotterRow, new()
{ }

this ViewModel contains one property :

private Product sp;
public Product selectedProduct
{
   get { return sp; }
   set
   {
    sp = value; 
   }

}

I want to access this property(value) in BlotterCriteriaViewModel (other viewModel). All the viewmodels implements InotiFyPropertyChange. I have read some related questions but didnt get anything. I am not using frameworks(prism,galasoft)?

How to pass the property(value) here? Kindly suggest>

4

1 回答 1

1

好的,至少有两种方法。

  1. 直接方式:实例BlotterCriteriaViewModel获取对实例的引用TaskTrayViewModel(在构造时,或者可能在需要值的点)。有了TaskTrayViewModel引用,就可以轻松访问公共属性。
  2. 间接方式: 的实例从事件中BlotterCriteriaViewModel获取INotifyPropertyChange引用TaskTrayViewModel并订阅PropertyChanged事件。你不会得到属性的初始值,但是一旦属性发生变化,你就会得到事件并且可以在事件 args 中看到新的值。

这些有问题吗?

于 2012-11-19T10:27:18.073 回答