Skip to content

Commit 51e65d7

Browse files
committed
Make failing to create a command binding suck less
1 parent 43e7228 commit 51e65d7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ReactiveUI.Platforms/Xaml/CreatesCommandBinding.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ public IDisposable BindCommandToObject(ICommand command, object target, IObserva
5050
.Select(x => new { EventInfo = type.GetRuntimeEvent(x.Item1), Args = x.Item2 })
5151
.FirstOrDefault(x => x.EventInfo != null);
5252

53-
if (eventInfo == null) return null;
53+
if (eventInfo == null) {
54+
throw new Exception(
55+
String.Format(
56+
"Couldn't find a default event to bind to on {0}, specify an event expicitly",
57+
target.GetType().FullName));
58+
}
5459

5560
var mi = GetType().GetRuntimeMethods().First(x => x.Name == "BindCommandToObject" && x.IsGenericMethod);
5661
mi = mi.MakeGenericMethod(eventInfo.Args);
@@ -128,4 +133,4 @@ public IDisposable BindCommandToObject<TEventArgs>(ICommand command, object targ
128133
return null;
129134
}
130135
}
131-
}
136+
}

0 commit comments

Comments
 (0)