I need to pass an object from one view model to another. In my current implementation I created a static instance of the ProductVM, following this example, then accessed it's property from the instance . But passing a static instance doesn't seem like a solid design in the long run.
private static ProductVM _instance = new ProductVM();
public static ProductVMInstance { get { return _instance; } }
When researching alternatives to providing a static view model instance, I came across, constructor injection as an option.
Question:
Does anyone have any example, on how to implement ctor injection for passing of objects? (Preferably not using a third party framework)
ProductsVM: (view model that holds property to be sent)
public ProductModel SelectedProduct { get; set; }
CustomerOrdersVM: (view model that the SelectedProduct needs to be passed into)
public class CustomerOrdersViewModel : IPageViewModel
{
public CustomerOrdersViewModel()
{
}
}