0

I am trying to learn ReactiveUI, and am currently trying to set up the Routing feature. I have been "following" the Play rxui-5-update branch on github:

https://github.com/play/play-windows/tree/rxui5-update/Play

In my MainWindow.xaml where I am setting up the RoutedViewHost I am getting the following error:

Invalid cross-thread access

...on the following line:

The same error is generated within MainWindow.xaml of the rxui5 version of Play.

David
  • 15
  • 4
  • Call stackkkkkkkkkkkkk – Ana Betts Aug 11 '13 at 18:55
  • > System.Reactive.Core.dll!System.Reactive.Concurrency.AsyncLock.Wait(System.Action action) + 0x202 bytes System.Reactive.Linq.dll!System.Reactive.TailRecursiveSink>.Run.AnonymousMethod__0(System.Action self) + 0x65 bytes System.Reactive.Core.dll!System.Reactive.Concurrency.Scheduler.Schedule.AnonymousMethod__45(System.Action _action, System.Action> self) + 0x97 bytes – David Aug 12 '13 at 11:31
  • The runtime error is: Window must be the root of the tree. Cannot add Window as a child of Visual. The design time error is: Invalid cross-thread access – David Aug 12 '13 at 11:40
  • Another difference between my example and the Play example is that I am loading Windows into my RoutingViewHost as opposed to UserControls as in your example. – David Aug 12 '13 at 11:57

1 Answers1

0

You can't load Windows into a RoutingViewHost because it's a control. Load UserControls into the RoutingViewHost and create a top-level window whose contents are just a RoutingViewHost

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • That fixed it. Thanks Paul, Routing is now working. Now to include the message bus! – David Aug 13 '13 at 12:54
  • You really should avoid the message bus at all costs - it's a sign of bad design; using WhenAny to reach into child objects is usually better – Ana Betts Aug 13 '13 at 13:29