Skip to content

Getting Started with UPF

Robert Campbell edited this page Oct 15, 2022 · 3 revisions

The Ultraviolet Presentation Foundation (UPF) is a view provider for the Ultraviolet UI subsystem which is modeled after the Windows Presentation Foundation (WPF), a popular framework from Microsoft for designing Windows applications. UPF is considered a part of the Ultraviolet Framework, but not a core component. It must therefore be explicitly added to your application and configured before it can be used.

Installing UPF

The Presentation Foundation is available on NuGet through the Ultraviolet.Presentation package. Installing this package will add a reference to the Ultraviolet.Presentation.dll assembly to your project.

As of the 2018.04 release, UPF can be configured using Ultraviolet's new plugin architecture. In OnCreatingUltravioletContext(), add an instance of the Ultraviolet.Presentation.PresentationFoundationPlugin class to the Plugins collection exposed by the configuration object.

Prior to that release, UPF must be configured by calling the Configure() method on the Ultraviolet.Presentation.PresentationFoundation static type and passing in the configuration object as an argument.

Expressions Compiler

As described in the article on UPF binding expressions, the C# code fragments which bind your UPF views to their view models need to be compiled before they can be used. Another NuGet package, Ultraviolet.Presentation.Compiler, contains the Roslyn-based expression compiler which performs this task for you. If this package is not included in your project, then attempting to compile binding expressions will throw an exception at runtime.

Sample Projects

There are two sample projects which demonstrate how to define UPF views and include them in an application: Sample 12 - UPF and Sample 13 - UPF (Advanced). The code for these samples can be found in the Samples folder of the Ultraviolet repository.

Clone this wiki locally