Logrus
Topic Author
Posts: 54
Joined: 22 Jul 2015, 12:16

LoadXaml throws a warning "does not inherit from x: Class"

04 Oct 2020, 09:57

I have a class hierarchy:
class WindowEx : public NoesisApp::Window
{
...
};

class DesignerMainWindow : public WindowEx
{
...
};
Designer XAML
<Window
    x:Class="DesignerMainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    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">
    <Grid/>
</Window>

This is how the Designer class is instantiated correctly
			
auto symbol = Symbol("DesignerMainWindow");
			
if (Factory::IsComponentRegistered(symbol)) {
	if (auto component = DynamicPtrCast<WindowEx>(Factory::CreateComponent(symbol))) {
		component->SetIsActive(true);
		component->Show();
		return;
	}
}
And this is how it issues a warning,
"Component type 'WindowEx' does not inherit from x:Class type 'DesignerMainWindow'.."
auto root = Noesis::GUI::LoadXaml("Designer/DesignerMainWindow.xaml");
if (auto wnd = DynamicPtrCast<WindowEx>(root)) {
}
The window is created, but the style specified in WindowEx is not inherited
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: LoadXaml throws a warning "does not inherit from x: Class"

07 Oct 2020, 10:49

Is it possible that you are defining a xaml for WindowEx and you are calling LoadComponent for WindowEx constructor too?
You can't do that, only the instantiated class can have an associated xaml.

But you can define a ControlTemplate for WindowEx and then use it in your DesignerMainWindow by setting its Template property (explicitly or using a style).
 
Logrus
Topic Author
Posts: 54
Joined: 22 Jul 2015, 12:16

Re: LoadXaml throws a warning "does not inherit from x: Class"

07 Oct 2020, 13:25

Yes, in the WindowEx constructor, I called LoadComponent.

Thanks
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: LoadXaml throws a warning "does not inherit from x: Class"

13 Oct 2020, 16:36

Were you able to make it work using the ControlTemplate as I suggested?
Can we mark this as solved?
 
Logrus
Topic Author
Posts: 54
Joined: 22 Jul 2015, 12:16

Re: LoadXaml throws a warning "does not inherit from x: Class"

15 Oct 2020, 18:36

Yes, it works with ControlTemplate.
Thanks
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: LoadXaml throws a warning "does not inherit from x: Class"

15 Oct 2020, 18:41

Great, thanks for the update.

Who is online

Users browsing this forum: Bing [Bot] and 8 guests