Open HO-COOH opened 1 year ago
Do you see the same issue if you just use Window in your Xaml file?
https://github.com/microsoft/microsoft-ui-xaml/assets/52577874/80d34335-0d4b-4e63-8fc7-134c5f01711e
Following your instructions as closely as I could, I didn't see anything like you described. I did, however, have this WindowEX separated out in a separate WinRT component.
@DarranRowe Now things get interesting. I tried separated out the WindowEx
class into a winrt component project and things indeed worked. You can reproduce my issue if you don't separate it out.
And to answer your question, as I said I need to add custom logic to my WindowEx
class (extra properties), so I need to use it as the root window object in Xaml.
One thing that I did notice is that if the extended window type is defined in the executable, the generated code has it specifying WindowEX in the list of implemented types:
//MainWindow.xaml.g.h
...
namespace winrt::CmpTest2::implementation
{
using IInspectable = ::winrt::Windows::Foundation::IInspectable;
template <typename D, typename ... I>
struct MainWindowT : public ::winrt::CmpTest2::implementation::MainWindow_base<D,
::winrt::CmpTest2::implementation::WindowEX,
I...>
...
However, when it is in a separate component, then this doesn't occur:
//MainWindow.xaml.g.h
...
namespace winrt::CmpTest::implementation
{
using IInspectable = ::winrt::Windows::Foundation::IInspectable;
template <typename D, typename ... I>
struct MainWindowT : public ::winrt::CmpTest::implementation::MainWindow_base<D,
::winrt::Microsoft::UI::Xaml::Markup::IComponentConnector,
I...>
...
There is also that lack of IComponentConnector and this seems to be the problem.
the generated code has it specifying WindowEX in the list of implemented types:
@DarranRowe This is expected since when the base class is in a different component, the actual implementation type is not accessible to you.
This is still an issue today, and I am still not able to inherit a custom Window (defined within in the same project) and have to rewrite quite a lot of logic
Describe the bug
I subclass (inherit)
Microsoft.UI.Xaml.Window
to add some custom logic. The project builds and runs, and the controls are there. But all event handlers defined in Xaml (likeButton Click
) failed to execute.This only happens in C++/WinRT. C# project works fine.
Steps to reproduce the bug
Subclass
Microsoft.UI.Xaml.Window
, here is the idlMainWindow.xaml
MainWindow.idl
Expected behavior
No response
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.4.2: 1.4.231008000
Windows version
Windows 10 (1809): Build 17763
Additional context
No response