LoadXaml throws a warning "does not inherit from x: Class"
I have a class hierarchy:
Designer XAML
This is how the Designer class is instantiated correctly
And this is how it issues a warning,
"Component type 'WindowEx' does not inherit from x:Class type 'DesignerMainWindow'.."
The window is created, but the style specified in WindowEx is not inherited
Code: Select all
class WindowEx : public NoesisApp::Window
{
...
};
class DesignerMainWindow : public WindowEx
{
...
};
Code: Select all
<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>
Code: Select all
auto symbol = Symbol("DesignerMainWindow");
if (Factory::IsComponentRegistered(symbol)) {
if (auto component = DynamicPtrCast<WindowEx>(Factory::CreateComponent(symbol))) {
component->SetIsActive(true);
component->Show();
return;
}
}
"Component type 'WindowEx' does not inherit from x:Class type 'DesignerMainWindow'.."
Code: Select all
auto root = Noesis::GUI::LoadXaml("Designer/DesignerMainWindow.xaml");
if (auto wnd = DynamicPtrCast<WindowEx>(root)) {
}
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: LoadXaml throws a warning "does not inherit from x: Class"
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).
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).
Re: LoadXaml throws a warning "does not inherit from x: Class"
Yes, in the WindowEx constructor, I called LoadComponent.
Thanks
Thanks
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: LoadXaml throws a warning "does not inherit from x: Class"
Were you able to make it work using the ControlTemplate as I suggested?
Can we mark this as solved?
Can we mark this as solved?
Re: LoadXaml throws a warning "does not inherit from x: Class"
Yes, it works with ControlTemplate.
Thanks
Thanks
-
sfernandez
Site Admin
- Posts: 2997
- Joined:
Re: LoadXaml throws a warning "does not inherit from x: Class"
Great, thanks for the update.
Who is online
Users browsing this forum: Bing [Bot] and 8 guests