ReactorUI
  • What's ReactorUI for Xamarin
  • Guide
    • Setting up
    • Hello World Sample
    • Components
      • Component Lifecycle
      • Component Properties
      • Component with children
      • Navigation
      • Component Context
      • Reference to native controls
      • Animation
  • Native Tree and Visual Tree
    • Custom visual nodes
    • Custom Pages
  • Migrating from MVVM model
  • Integrating DI Containers
  • Hot reload troubleshooting
  • Styling and theming
  • Sample with SkiaSharp
Powered by GitBook
On this page

Was this helpful?

  1. Guide
  2. Components

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"];
PreviousNavigationNextReference to native controls

Last updated 5 years ago

Was this helpful?