using System;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using Avalonia.Animation;
using Avalonia.Controls;
using Avalonia.Styling;
using Avalonia;
using ReactiveUI;
using Splat;
namespace Avalonia.ReactiveUI
{
///
/// This control hosts the View associated with ReactiveUI RoutingState,
/// and will display the View and wire up the ViewModel whenever a new
/// ViewModel is navigated to. Nested routing is also supported.
///
///
///
/// ReactiveUI routing consists of an IScreen that contains current
/// RoutingState, several IRoutableViewModels, and a platform-specific
/// XAML control called RoutedViewHost.
///
///
/// RoutingState manages the ViewModel navigation stack and allows
/// ViewModels to navigate to other ViewModels. IScreen is the root of
/// a navigation stack; despite the name, its views don't have to occupy
/// the whole screen. RoutedViewHost monitors an instance of RoutingState,
/// responding to any changes in the navigation stack by creating and
/// embedding the appropriate view.
///
///
/// Place this control to a view containing your ViewModel that implements
/// IScreen, and bind IScreen.Router property to RoutedViewHost.Router property.
///
///
///
///
///
///
/// ]]>
///
///
///
/// See
/// ReactiveUI routing documentation website for more info.
///
///
public class RoutedViewHost : TransitioningContentControl, IActivatableView, IEnableLogger
{
///
/// for the property.
///
public static readonly StyledProperty RouterProperty =
AvaloniaProperty.Register(nameof(Router));
///
/// Initializes a new instance of the class.
///
public RoutedViewHost()
{
this.WhenActivated(disposables =>
{
var routerRemoved = this
.WhenAnyValue(x => x.Router)
.Where(router => router == null)!
.Cast