I assign a datacontext to a CustomControl using this XAML:
<Setter Property="DataContext" Value="{Binding TimeUnitGridViewModel, Mode=OneWay, Source={StaticResource Locator}}" />
This works as expected. The 'Locator' is an MVVMlight ViewModelLocator declared in the resources for the file.
How would I rewrite this XAML to allow for passing a parameter into the constructor of the ViewModel? I should be able to use property injection but I've no idea on the syntax.
EDIT:
This is the code I use in the ViewModelLocator:
public TimeUnitGridViewModel TimeUnitGridViewModel
{
get
{
return ServiceLocator.Current.GetInstance<TimeUnitGridViewModel>(Guid.NewGuid().ToString());
}
}