Reputation: 393
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>
Upvotes: 0
Views: 1865
Reputation: 35584
Okay, there are at least two ways.
BlotterCriteriaViewModel
gets a reference to the instance of TaskTrayViewModel
(either at the construction time, or maybe at the point where the value is needed). Having the TaskTrayViewModel
reference, public properties can be easily accessed.BlotterCriteriaViewModel
gets the INotifyPropertyChange
reference from TaskTrayViewModel
and subscribes to PropertyChanged
event. You won't get the initial value of the property, but as soon as the property changes, you get the event and can see the new value in the event args.Is there a problem with any of these?
Upvotes: 1