Class ReactivePage<TViewModel>
- Namespace
- ReactiveUI.Maui
- Assembly
- ReactiveUI.Maui.dll
A Page that is reactive.
[RequiresDynamicCode("ReactivePage uses methods that require dynamic code generation")]
[RequiresUnreferencedCode("ReactivePage uses methods that may require unreferenced code")]
public class ReactivePage<TViewModel> : Page, INotifyPropertyChanged, IVisualTreeElement, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, ILayout, IPageController, IVisualElementController, IElementController, IElementConfiguration<Page>, ISafeAreaView, IView, ITransform, ITitledElement, IElement, IToolbarElement, IViewFor<TViewModel>, IViewFor, IActivatableView where TViewModel : class
Type Parameters
TViewModelThe type of the view model backing the view.
- Inheritance
-
ReactivePage<TViewModel>
- Implements
-
IView
For <TViewModel>
- Inherited Members
- Extension Methods
Remarks
This class is a Page that is also reactive. That is, it implements IViewFor<T>. You can extend this class to get an implementation of IViewFor<T> rather than writing one yourself.
Note that the XAML for your control must specify the same base class, including the generic argument you provide for your view
model. To do this, use the TypeArguments attribute as follows:
<rxui:ReactivePage
x:Class="Foo.Bar.Views.YourView"
x:TypeArguments="vms:YourViewModel"
xmlns:rxui="http://reactiveui.net"
xmlns:vms="clr-namespace:Foo.Bar.ViewModels"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<!-- view XAML here -->
</rxui:ReactivePage>
Note that UWP and WinUI projects do not support the TypeArguments attribute. The XAML designer window in WPF projects also does not
support generic types. To use ReactivePage<TViewModel> in XAML documents you need to create a base class
where you derive from ReactivePage<TViewModel> with the type argument filled in.
internal class YourViewBase : ReactivePage<YourViewModel> { /* No code needed here */ }
public partial class YourView : YourViewBase
{
/* Your code */
}
Then you can use this base class as root in your XAML document.
<views:YourViewBase
x:Class="Foo.Bar.Views.YourView"
xmlns:rxui="http://reactiveui.net"
xmlns:vms="clr-namespace:Foo.Bar.ViewModels"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<!-- view XAML here -->
</views:YourViewBase>
Constructors
ReactivePage()
Fields
ViewModelProperty
The view model bindable property.
Field Value
Properties
BindingRoot
Gets the binding root view model.
Property Value
- TView
Model
ViewModel
Gets or sets the strongly typed view model. Override this property to integrate with the platform's binding system.
Property Value
- TView
Model
Methods
OnBindingContextChanged()
Invoked whenever the binding context of the page changes. Override this method to add class handling for this event.