Search code examples
c#avalonia

Avalonia - how to create new window?


I'm trying to get familiar with Avalonia, and porting one of my projects to it.

I have a problem with creating new windows - I use manual from Tutorial, and get just .xaml.cs file in my Solution Explorer: enter image description here

File AboutView.xaml is created in project folder, contains

<Window 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"
    mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
    x:Class="MyProjectName.Views.AboutView"
    Title="AboutView">
Welcome to Avalonia!

but not shown. AboutView.xaml.cs contains the following code, and shows error:

enter image description here

What am i doing wrong?


Solution

  • I fixed this by switching to the file system (or something similar) in the explorer, and finding the file with the .csproj extension. I removed this configuration section and the problem disappeared:

    <ItemGroup>
        <Page Include="Views\AdditionalWindow.xaml">
            <SubType>Designer</SubType>
        </Page>
    </ItemGroup>