Why is [Windows :: Foundation :: Metadata :: WebHostHidden] added by default to WinRT C ++ / CX user controls?

When I create a new control in a WinRT C ++ / CX project, the attribute of the [Windows::Foundation::Metadata::WebHostHidden] added by default to Visual Studio 2012.

Example:

 namespace WindowsRuntimeComponent1 { [Windows::Foundation::Metadata::WebHostHidden] public ref class MyUserControl sealed { public: MyUserControl(); }; } 
  • Is there a documented reason? (I did my homework, but I could not find this information)
  • As far as I know, using the [WebHostHidden] attribute makes the class invisible to WinRT HTML / Javascript projects. Does this mean that I cannot create a control in C ++ / CX that can be used in Javascript?
+7
source share
1 answer

As far as I know, using the [WebHostHidden] attribute makes the class invisible to WinRT HTML / JavaScript projects.

That's right: this attribute hides the type in the JavaScript projection, so from JavaScript it looks like the type does not exist.

Does this mean that I cannot create a control in C ++ / CX that can be used in JavaScript?

You cannot use XAML controls with JavaScript period. When using JavaScript, the user interface is created using HTML, not XAML.

+15
source

All Articles