Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 636b376

Browse files
author
Meaghan Lewis
authored
Merge pull request #2362 from github/fixes/null-view-model
Return a null view for a null view-model
2 parents 74303c6 + 974fbee commit 636b376

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/GitHub.VisualStudio.UI/Views/ViewLocator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ public class ViewLocator : IValueConverter
3232
/// <param name="culture">Unused.</param>
3333
/// <returns>
3434
/// A new instance of a view for the specified view model, or an error string if a view
35-
/// could not be located.
35+
/// could not be located. A null view model will return null.
3636
/// </returns>
3737
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
3838
{
39+
if (value == null)
40+
{
41+
// Return null for a null view model
42+
return null;
43+
}
44+
3945
var exportViewModelAttribute = value.GetType().GetCustomAttributes(typeof(ExportAttribute), false)
4046
.OfType<ExportAttribute>()
4147
.Where(x => typeof(IViewModel).IsAssignableFrom(x.ContractType))

0 commit comments

Comments
 (0)