Created
October 2, 2017 11:52
-
-
Save BrightShadow/56e18c3de21e9bc763427abef299c2d1 to your computer and use it in GitHub Desktop.
AddDataTemplate method for WPFViewModelResolver class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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