WPF ReactiveUI Binding and Routing Tutorial

Reactive UI clearly helps to write cleaner and more intuitive code, you just have to get used to bindings and thinking about Observables. There’s a lot of information and projects about Reactive UI but i didn’t find any project/tutorial showing a “complete” build just stubs or code excerptions.

So here’s my attempt to do it: https://github.com/kondaskondas/FirstsStepsRUI

This repository covers the basics; setting up the bootstrapper, bindings and routing. The demo just takes a username and password and has a side menu to change views.

Common “gotchas”:

  • Don’t forget to include System, System.Linq, System.Reactive.Linq and ReactiveUI namespaces to get all the extensions methods.
  • Use WhenAny for tracking changes of a property and WhenAnyValues to check and validate multiple properties
  • ReactiveCommand.CreateAsyncTask (And other Create functions) are only to hook the tasks to do (calling functions), do result validation, business logic, UI operations, etc. always on Subscribe(…).
  • If you’re updating UI from a Observable(Commands, Events, etc) do it on the Reactive MainThreadScheduler : ObserveOn(RxApp.MainThreadScheduler).Subscribe(…)
  • If the solution doesn’t looks simple, you are over thinking it or taking the wrong approach (Think with Observables or don’t).

Recommended reads:

Still trying to figure out if using Caliburn.Micro is a good idea, the only benefit i see is property auto-wiring when doing simple views. If anyone has a good link for using both (Caliburn.Micro and ReactiveUI) don’t hesitate to tell me!. If you see an error on the code or a better approach please write a comment.


ReactiveUI Reactive UI Tutorial Rx MVVM C# Routing Binding IViewFor

Like what you read? Give kondas a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.