codeliftsleep
Topic Author
Posts: 2
Joined: 19 Feb 2018, 04:59

Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

20 Feb 2018, 15:24

Ok, so I have things working somewhat properly in Blend but in Unity I get the above referenced error when I try and run the project...

What am I doing wrong?
 
User avatar
jsantos
Site Admin
Posts: 4174
Joined: 20 Jan 2012, 17:18
Contact:

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

21 Feb 2018, 12:34

Is your MainWindow.xaml.cs inside the Assets/ folder? Is it under the namespace WPFBlend? Could you paste it here with the corresponding XAML please?
 
kaijin
Posts: 9
Joined: 29 Feb 2024, 18:54

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

05 Dec 2024, 01:19

Getting this error trying to make a new xaml file attached to a new scene. It's probably something very rudimentary, I just don't know C#
Assets/Scenes/Scene2/AnotherWindowMainView.xaml(1,14): Unknown x:Class type 'VelBlend2.AnotherWindowMainView'
UnityEngine.Debug:LogError (object,UnityEngine.Object)
AnotherWindowMainView.xaml
<UserControl x:Class="VelBlend2.AnotherWindowMainView"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Border Background="DodgerBlue" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="50,20">
    <StackPanel>
      <TextBlock Text="Hello World" FontSize="30" Foreground="White"/>
      <Button Content="Button" Margin="0,10,0,0"/>
    </StackPanel>
  </Border>
</UserControl>
AnotherWindowMainView.xaml.cs
#if UNITY_5_3_OR_NEWER
#define NOESIS
using Noesis;
#else
using System;
using System.Windows.Controls;
#endif

namespace VelBlend2
{
    /// <summary>
    /// Interaction logic for AnotherWindowMainView.xaml
    /// </summary>
    public partial class AnotherWindowMainView : UserControl
    {
        public AnotherWindowMainView()
        {
            InitializeComponent();
        }

#if NOESIS
        private void InitializeComponent()
        {
            NoesisUnity.LoadComponent(this);
        }
#endif
    }
}
 
kaijin
Posts: 9
Joined: 29 Feb 2024, 18:54

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

05 Dec 2024, 01:57

Welp restarting Unity, it decided it's ok with it, no more error. I am still having a problem in Blend; I can open the XAML Designer for a xaml from a Noesis sample, but making any additional xaml files the Designer won't open, despite looking fine and working in Unity.
 
User avatar
sfernandez
Site Admin
Posts: 3183
Joined: 22 Dec 2011, 19:20

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

05 Dec 2024, 11:00

Getting this error trying to make a new xaml file attached to a new scene. It's probably something very rudimentary, I just don't know C#
It probably showed if you saved the .xaml first and then the .cs, so Unity didn't compile it before processing the xaml file.
I am still having a problem in Blend; I can open the XAML Designer for a xaml from a Noesis sample, but making any additional xaml files the Designer won't open
Which version are you using? We recommed sticking to Visual Studio Blend 2019, as newer versions reimplemented the Designer from scratch for .NET and are lacking many features and still show problems.

That is one of the reasons we are working on our own tool for authoring UI, Noesis Studio (made with Noesis itself, multiplatform and supporting all our extensions) that we plan to make public next year.
 
kaijin
Posts: 9
Joined: 29 Feb 2024, 18:54

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

06 Dec 2024, 17:26

Well progress sort of, at least now Visual Studio is throwing an error when trying to open XAML with Designer

"The file cannot be opened with the selected editor. Please choose another editor."
 
User avatar
sfernandez
Site Admin
Posts: 3183
Joined: 22 Dec 2011, 19:20

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

10 Dec 2024, 15:16

Are you trying to open the XAML files directly in the csproj/sln created by Unity? That project is not compatible with WPF/XAML designer. If you take a look at our samples you will see we provide a different solution and project for editing the xamls in Blend. Could you try that?
 
kaijin
Posts: 9
Joined: 29 Feb 2024, 18:54

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

14 Dec 2024, 20:09

It seems like you’re saying that not all the Unity samples are the same? There are samples from Github, samples from the in-Unity package manager, samples from the Unity Package download from the Noesis site, and templates from the Visual Studio Extension (which don’t appear to be working in 2019). Which samples should I look at?
 
User avatar
sfernandez
Site Admin
Posts: 3183
Joined: 22 Dec 2011, 19:20

Re: Unity Error: "Unknown x:Class type WPFBlend.MainWindow"

16 Dec 2024, 12:03

I was able to correctly install "NoesisGUI Unity Project Templates 2019" in Visual Studio 2019 (not Blend), and create a Unity App (NoesisGUI) project. Then downloaded the NoesisGUI Unity package from our downloads page, copied it to the LocalPackages as explained in the Getting started page when the project is created, and finally opened the project in Unity. It worked as expected.

Regarding my previous message, I was trying to explain that Unity has an entry in the menu "Assets > Open C# project" that opens a project that is not compatible with editing XAML files in the designer, as it is not a WPF project. Is it possible you were opening that project to edit xamls?

But our samples included in the Unity packge, the ones you can import from the Package Manager, each one of them includes a Blend project you can open to edit the xamls in the designer with the appropriate preview. Have you tried them?

Who is online

Users browsing this forum: Ahrefs [Bot] and 9 guests