Skip to content

Commit 17d5bfa

Browse files
authored
fix: Fix when a combobox SelectedIndex -1 it would crash (#1927)
1 parent ea99102 commit 17d5bfa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/ReactiveUI/Platforms/windows-common/ViewModelViewHost.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ private void ResolveViewForViewModel(object viewModel, string contract)
181181

182182
if (viewInstance == null)
183183
{
184-
throw new Exception($"The {nameof(ViewModelViewHost)} could not find a valid view for the view model of type {viewModel.GetType()} and value {viewModel}.");
184+
Content = DefaultContent;
185+
this.Log().Warn($"The {nameof(ViewModelViewHost)} could not find a valid view for the view model of type {viewModel.GetType()} and value {viewModel}.");
186+
return;
185187
}
186188

187189
viewInstance.ViewModel = viewModel;

0 commit comments

Comments
 (0)