Xaml Content WinUI Runtime Component

Rebeka Fox 106 Reputation points
2022-11-23T11:46:04.003+00:00

I've been working with an unpackaged app where I've been loading runtime components using base.h functions and getting an Interface I declared in a proxy server. So it made sense that Xaml content in a WinUI Runtime Component would fail under these circumstances. But now I've linked to the winmd file and included the winrt/header.h, and I put the Xaml file in the executable folder; I even declare the activatableClass in the app.manifest. I load the page using Frame.Navigate. The page loads no problem, the class loads no problem. Initialize is called and succeeds, but none of the Events are fired like Loaded or the mouse Click. When I click the button it is visually animated, but the Event does not fire. Bing as usual produces no satisfactory answer for this. A gentleman on Twitter said he loads Xaml content from a WinUI Runtime Components all the time .. . . The only threading models I have are STA, MTA, or Both, and I'm wondering if it's because the FrameworkElement is not being created on the same thread as the main UI? Is there something I'm missing or is this just not possible?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
749 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rebeka Fox 106 Reputation points
    2022-11-25T07:32:32.28+00:00

    I'm not the best at this so this was probably obvious. As a self-contained app you must put both the Xaml and the xbf file in the executable directory. As an aside. For everyone asking about plugins but never getting an answer, use WINRT_IMPL_LoadLibraryW and WINRT_IMPL_GetProcAddress and pass it the typename value to get the IActivationFactory and ask for a MUXC::Page. With the Xaml and the xbf in the executable folder, a BlankPage template example works fine in my test. I can't seem to get TypeName to work with the app.manifest without actually referencing the module.

    [just my observations]

    0 comments No comments