Browse Source
Merge pull request #9054 from workgroupengineering/fixes/ControlCatalog
fix: Avoid Cast exception on Single View Application
disbar
Max Katz
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
7 deletions
-
samples/ControlCatalog/MainView.xaml.cs
-
samples/ControlCatalog/Pages/ScreenPage.cs
|
|
|
@ -2,10 +2,10 @@ using System; |
|
|
|
using System.Collections; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.ApplicationLifetimes; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Media.Immutable; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.Themes.Fluent; |
|
|
|
using ControlCatalog.Models; |
|
|
|
using ControlCatalog.Pages; |
|
|
|
@ -20,7 +20,7 @@ namespace ControlCatalog |
|
|
|
|
|
|
|
var sideBar = this.Get<TabControl>("Sidebar"); |
|
|
|
|
|
|
|
if (AvaloniaLocator.Current?.GetService<IRuntimePlatform>()?.GetRuntimeInfo().IsDesktop == true) |
|
|
|
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime) |
|
|
|
{ |
|
|
|
var tabItems = (sideBar.Items as IList); |
|
|
|
tabItems?.Add(new TabItem() |
|
|
|
@ -28,7 +28,6 @@ namespace ControlCatalog |
|
|
|
Header = "Screens", |
|
|
|
Content = new ScreenPage() |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var themes = this.Get<ComboBox>("Themes"); |
|
|
|
|
|
|
|
@ -2,7 +2,6 @@ using System; |
|
|
|
using System.Globalization; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.Media; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.Rendering; |
|
|
|
@ -18,8 +17,10 @@ namespace ControlCatalog.Pages |
|
|
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|
|
|
{ |
|
|
|
base.OnAttachedToVisualTree(e); |
|
|
|
Window w = (Window)VisualRoot!; |
|
|
|
w.PositionChanged += (sender, args) => InvalidateVisual(); |
|
|
|
if(VisualRoot is Window w) |
|
|
|
{ |
|
|
|
w.PositionChanged += (_, _) => InvalidateVisual(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public override void Render(DrawingContext context) |
|
|
|
@ -27,7 +28,7 @@ namespace ControlCatalog.Pages |
|
|
|
base.Render(context); |
|
|
|
if (!(VisualRoot is Window w)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
var screens = w.Screens.All; |
|
|
|
var scaling = ((IRenderRoot)w).RenderScaling; |
|
|
|
|