Permalink
Browse files

Allow NSViews to be directly used as IViewFor's

  • Loading branch information...
1 parent 6dfee99 commit 566be0a199bcd7ff7976b7585fc0431195de3403 @paulcbetts paulcbetts committed Mar 12, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 ReactiveUI.Cocoa/RoutedViewHost.cs
@@ -32,7 +32,14 @@ public RoutedViewHost(NSView targetView)
var view = RxRouting.ResolveView(vm);
view.ViewModel = vm;
- viewLastAdded = ((NSViewController)view).View;
+ if (view is NSViewController) {
+ viewLastAdded = ((NSViewController)view).View;
+ } else if (view is NSView) {
+ viewLastAdded = (NSView)view;
+ } else {
+ throw new Exception(String.Format("'{0}' must be an NSViewController or NSView", view.GetType().FullName));
+ }
+
targetView.AddSubview(viewLastAdded);
}, ex => RxApp.DefaultExceptionHandler.OnNext(ex));
}

0 comments on commit 566be0a

Please sign in to comment.