I would recommend using an IoC container and configure your container to supply the parameter when building.
For example, here the typical code for UserControl looks for me in WPF:
public partial class MyDataGridView : IMyListView { public MyDataGridView() { InitializeComponent(); } public MyDataGridView(MyListViewModel viewModel) { InitializeComponent(); DataContext = viewModel; } }
StructureMap creates MyListViewModel for me because by default it searches for the most greedy constructor and then provides dependencies. In my StructureMap configuration, I can indicate that MyListViewModel will be provided with any parameters needed when building this object.
In a container like StructureMap, I don't need βnewβ objects. Ever.
source share