Component Context

Any derived RxComponent class can access a Context property that returns a RxContext object shared with any other component in the visual tree.

An RxContext is essentially a Dictionary<string, object> that you can use to store or retrive global variables: for example a service container object or current logged user.

RxApplication can be created also passing a value in the Context of the root component; for example in the following code we are passing a service provider object to the root component:

ServiceProvider = RegisterServices();
_app = RxApplication.Create<ShellComponent>(this)
    .WithContext("ServiceProvider", ServiceProvider)

Any component under root component can access the context:

var serviceProvider = (IServiceProvider)Context["ServiceProvider"];

Last updated