Often it’s necessary to show or hide UI elements based on the users authentication. This short post will show a way to use an application context to work as source.
The application context is a class I have placed in the root of my project. It contain a static property called Current used to gain easy access to it’s properties. It implements INotifyPropertyChanged so it’s possible to notify if a property is changed. In this sample I have added a bool property called IsAuthenticated.
To actually use the application context in bindings in the xaml it’s necessary to point to a resource that points to the class. In the sample below I have called the namespace root and called the resource Context. Furthermore I have added a resource to a bool to visibility converter from the Quebec framework and called it BoolToVisibilityConverter.