'App' does not contain a definition for 'InitializeComponent' #8837
Replies: 1 comment
-
Since you don't give much information on this "App", then this is going to be a complete and utter guess. The type that I use for "App" is defined as follows. It is C++ due to my working all of this out in C++. The namespace matches the root namespace of my application, but it isn't special. The class name, IslandApplication, is also not special. I just chose it to represent the fact that this is an application type for Xaml Islands.
There is a lot of C++ isms here. The important thing to note is that InitializeComponent is something that I defined myself. This does mean that you can't rely on the application class itself initialising the metadata provider and Xaml resources. This has to be done manually.
As you can see, this code activates any metadata providers that you want to use. The second one is a custom control. It then activates an instance of IslandApplication, passing in all metadata providers. This is needed because the Xaml runtime will query this in certain circumstances to figure out type information. This code is generated by the Xaml compiler in a WinUI 3 application. Next, an instance of XamlControlsResources is activated and added to the Application's resources. This is what normally happens in the Xaml compiler's generated InitializeComponent implementation. For completion's sake, here is the source file for IslandApplication too.
Hopefully this will help you adapt it to C#. |
Beta Was this translation helpful? Give feedback.
-
When I try to use winUI controls with xaml island in wpf (i will use the xaml code in uno platform later , anyway), i got issue like this
'App' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent'
Beta Was this translation helpful? Give feedback.
All reactions