-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DevTools can't inspect views that aren't windows or single view of a mobile app #10296
Comments
I don't agree to copletaly revert the PR. Original PR can manage both path, see this. If you want, I can fix the current behavior to handle both molality. |
Hi, @kekekeks
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
{
desktopLifetime.MainWindow = new MainWindow();
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime)
{
singleViewLifetime.MainView = new MainView();
}
base.OnFrameworkInitializationCompleted();
+ this.AttachDevTools(new()
+ {
+ StartupScreenIndex = 1,
+ });
}
}
using System;
using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
namespace MobileSandbox.Desktop
{
static class Program
{
[STAThread]
- static int Main(string[] args) =>
- BuildAvaloniaApp()
+ static int Main(string[] args)
+ {
+ var lt = new MyClass();
+ var app = BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
+ lt.Start();
+ return app;
+ }
/// <summary>
/// This method is needed for IDE previewer infrastructure
@@ -18,4 +25,17 @@ public static AppBuilder BuildAvaloniaApp()
.UsePlatformDetect()
.LogToTrace();
}
+
+ class MyClass : ISingleViewApplicationLifetime
+ {
+ public Control MainView { get ; set; }
+ public void Start()
+ {
+ var host = new MainWindow()
+ {
+ Content = MainView,
+ };
+ host.Show();
+ }
+ }
} And i try run, it work as expected. |
|
Note, that application lifetimes have always been an entirely optional feature and are documented as such. Even This is important for various embedding scenarios like this one: unreal.mp4 |
OK! I got it. Can you give me a sample repo to try and fix this?
|
@workgroupengineering [STAThread]
public static void Main(string[] args)
{
BuildAvaloniaApp().Start(AppMain, args);
}
private static void AppMain(Application app, string[] args)
{
app.Run(new MainWindow());
}
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace(); |
The issue AvaloniaUI/Avalonia#10296 has been fixed so we can now remove this workaround.
For some reason it's now tightly coupled with application lifetimes (those aren't guaranteed to be present at all) and only shows windows or the main view. So it's no longer possible to inspect any embedded TopLevels.
Since it's a regression from 0.10.x I'm considering to revert #6771
The text was updated successfully, but these errors were encountered: