diff --git a/src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs b/src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs index 68442c1fd3..7b65cfb595 100644 --- a/src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs +++ b/src/Avalonia.OpenGL/Controls/OpenGlControlBase.cs @@ -146,6 +146,13 @@ namespace Avalonia.OpenGL.Controls return false; } + if (_context == null) + { + Logger.TryGet(LogEventLevel.Error, "OpenGL")?.Log("OpenGlControlBase", + "Unable to initialize OpenGL: unable to create additional OpenGL context."); + return false; + } + GlVersion = _context.Version; try { diff --git a/src/Avalonia.ReactiveUI/RoutedViewHost.cs b/src/Avalonia.ReactiveUI/RoutedViewHost.cs index 9269dc70f8..775014d419 100644 --- a/src/Avalonia.ReactiveUI/RoutedViewHost.cs +++ b/src/Avalonia.ReactiveUI/RoutedViewHost.cs @@ -64,6 +64,12 @@ namespace Avalonia.ReactiveUI public static readonly StyledProperty ViewContractProperty = AvaloniaProperty.Register(nameof(ViewContract)); + /// + /// for the property. + /// + public static readonly StyledProperty DefaultContentProperty = + ViewModelViewHost.DefaultContentProperty.AddOwner(); + /// /// Initializes a new instance of the class. /// @@ -106,6 +112,15 @@ namespace Avalonia.ReactiveUI set => SetValue(ViewContractProperty, value); } + /// + /// Gets or sets the content displayed whenever there is no page currently routed. + /// + public object? DefaultContent + { + get => GetValue(DefaultContentProperty); + set => SetValue(DefaultContentProperty, value); + } + /// /// Gets or sets the ReactiveUI view locator used by this router. /// diff --git a/src/Avalonia.ReactiveUI/TransitioningContentControl.cs b/src/Avalonia.ReactiveUI/TransitioningContentControl.cs deleted file mode 100644 index d26e90b2da..0000000000 --- a/src/Avalonia.ReactiveUI/TransitioningContentControl.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Threading; - -using Avalonia.Animation; -using Avalonia.Controls; -using Avalonia.Styling; - -namespace Avalonia.ReactiveUI -{ - /// - /// A ContentControl that animates the transition when its content is changed. - /// - [Obsolete("Use TransitioningContentControl in Avalonia.Controls namespace")] - public class TransitioningContentControl : ContentControl, IStyleable - { - /// - /// for the property. - /// - public static readonly StyledProperty PageTransitionProperty = - AvaloniaProperty.Register(nameof(PageTransition), - new CrossFade(TimeSpan.FromSeconds(0.5))); - - /// - /// for the property. - /// - public static readonly StyledProperty DefaultContentProperty = - AvaloniaProperty.Register(nameof(DefaultContent)); - - private CancellationTokenSource? _lastTransitionCts; - - /// - /// Gets or sets the animation played when content appears and disappears. - /// - public IPageTransition? PageTransition - { - get => GetValue(PageTransitionProperty); - set => SetValue(PageTransitionProperty, value); - } - - /// - /// Gets or sets the content displayed whenever there is no page currently routed. - /// - public object? DefaultContent - { - get => GetValue(DefaultContentProperty); - set => SetValue(DefaultContentProperty, value); - } - - /// - /// Gets or sets the content with animation. - /// - public new object? Content - { - get => base.Content; - set => UpdateContentWithTransition(value); - } - - /// - /// TransitioningContentControl uses the default ContentControl - /// template from Avalonia default theme. - /// - Type IStyleable.StyleKey => typeof(ContentControl); - - /// - /// Updates the content with transitions. - /// - /// New content to set. - private async void UpdateContentWithTransition(object? content) - { - _lastTransitionCts?.Cancel(); - _lastTransitionCts = new CancellationTokenSource(); - - if (PageTransition != null) - await PageTransition.Start(this, null, true, _lastTransitionCts.Token); - base.Content = content; - if (PageTransition != null) - await PageTransition.Start(null, this, true, _lastTransitionCts.Token); - } - } -} diff --git a/src/Avalonia.ReactiveUI/ViewModelViewHost.cs b/src/Avalonia.ReactiveUI/ViewModelViewHost.cs index 16dee00ebc..869238b377 100644 --- a/src/Avalonia.ReactiveUI/ViewModelViewHost.cs +++ b/src/Avalonia.ReactiveUI/ViewModelViewHost.cs @@ -1,5 +1,8 @@ using System; using System.Reactive.Disposables; + +using Avalonia.Controls; + using ReactiveUI; using Splat; @@ -24,6 +27,12 @@ namespace Avalonia.ReactiveUI public static readonly StyledProperty ViewContractProperty = AvaloniaProperty.Register(nameof(ViewContract)); + /// + /// for the property. + /// + public static readonly StyledProperty DefaultContentProperty = + AvaloniaProperty.Register(nameof(DefaultContent)); + /// /// Initializes a new instance of the class. /// @@ -55,6 +64,15 @@ namespace Avalonia.ReactiveUI set => SetValue(ViewContractProperty, value); } + /// + /// Gets or sets the content displayed whenever there is no page currently routed. + /// + public object? DefaultContent + { + get => GetValue(DefaultContentProperty); + set => SetValue(DefaultContentProperty, value); + } + /// /// Gets or sets the view locator. /// diff --git a/tests/Avalonia.ReactiveUI.UnitTests/TransitioningContentControlTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/TransitioningContentControlTest.cs index 6ca617d2d4..daa3830b7d 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/TransitioningContentControlTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/TransitioningContentControlTest.cs @@ -12,14 +12,6 @@ namespace Avalonia.ReactiveUI.UnitTests { public class TransitioningContentControlTest { - [Fact] - public void Transitioning_Control_Should_Derive_Template_From_Content_Control() - { - var target = new TransitioningContentControl(); - var stylable = (IStyledElement)target; - Assert.Equal(typeof(ContentControl),stylable.StyleKey); - } - [Fact] public void Transitioning_Control_Template_Should_Be_Instantiated() {