xaml – Windows应用程序项目中不支持Type

如何从XAML样式或模板引用类型?
WPF语法在我的
Windows应用商店项目中不起作用.

IDE咆哮着“在Windows应用程序项目中不支持类型”.

解决方法

使用以下语法:

<Style TargetType="xmlNamespacePrefix:MyControlClassName" >
    ...

也就是说,您不需要在Windows应用商店和手机应用中使用{x:Type}语法.

MSDN说:

If you have used XAML for Windows Presentation Foundation (WPF),then
you might have used an x:Type markup extension to fill in any XAML
values that take a System.Type. The Windows Runtime XAML parser does
not support x:Type. Instead,you should refer to the type by name
without using any markup extension,and any necessary XAML-to-backing
type conversion is already handled by the built-in conversion behavior
in the XAML parser.

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.style.targettype

相关文章

发表回复

您的电子邮箱地址不会被公开。