Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BrightShadow/56e18c3de21e9bc763427abef299c2d1 to your computer and use it in GitHub Desktop.
Save BrightShadow/56e18c3de21e9bc763427abef299c2d1 to your computer and use it in GitHub Desktop.
AddDataTemplate method for WPFViewModelResolver class.
private void AddDataTemplate(Type viewType, Type viewModelType)
{
DataTemplate dataTemplate = this.CreateTemplate(viewType, viewModelType);
if (!Application.Current.Resources.Contains(dataTemplate.DataTemplateKey))
{
Application.Current.Resources.Add(dataTemplate.DataTemplateKey, dataTemplate);
}
else
{
Console.WriteLine("Duplicated resource key: " + dataTemplate.DataTemplateKey.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment