Why isn't InitializeComponent available for the Application class? #19065
-
So I've got my test project as follows: App.axaml: <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:TestApplication"
x:Class="TestApplication.App"
Title="App"
RequestedThemeVariant="Default">
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application> App.axaml.cs: using System;
using System.Reflection;
using System.Threading;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
[assembly: AssemblyTitle("TestApplication")]
namespace TestApplication;
public partial class App : Application {
[STAThread]
public static void Main(string[] args) {
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
new App();
}
public App() {
InitializeComponent();
}
private static AppBuilder BuildAvaloniaApp() {
return AppBuilder.Configure<App>().UsePlatformDetect().LogToTrace();
}
public override void Initialize() {
AvaloniaXamlLoader.Load(this);
}
} I really need to know, why isn't the
I even tried to ignore the error and tried building it, but it still fails with the same error Because I need to port over a WPF project over to Avalonia, and the stuff that's previously available for WPF isn't available in Avalonia. I tried looking everywhere for something similar, but no discussion has asked about the Application class specifically not working with I really need to know why. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can use on To be clear, Avalonia is not WPF. A lot things wont "just work" in Avalonia that work in WPF. For that you will need XPF. I also suggest reading some sample applications/docs. |
Beta Was this translation helpful? Give feedback.
You can use on
OnFrameworkInitializationCompleted
? You can also use theInitialize
method, but that might be too early.To be clear, Avalonia is not WPF. A lot things wont "just work" in Avalonia that work in WPF. For that you will need XPF. I also suggest reading some sample applications/docs.