Silverlight 4对x:TypeArguments的支持 [英] Silverlight 4 Support for x:TypeArguments
问题描述
我有一个通用基类,我想将其用于Silverlight页面.唯一的问题是x:TypeArguments属性似乎不起作用.
I've got a generic base page class that I'd like to use with my Silverlight pages. The only problem is that the x:TypeArguments attribute doesn't seem to be working.
该属性仅应用于XAML页面的根元素,而没有其他地方.
The attribute is only applied to the root element of the XAML page, and nowhere else.
我不断从编译器得到的错误消息是:"Using the generic type 'Base.BasePage<T>' requires 1 type arguments"
.此错误始终指向生成的Page.g.i.cs文件.
The error message I keep getting from the compiler is: "Using the generic type 'Base.BasePage<T>' requires 1 type arguments"
. This error is always pointing to the generated Page.g.i.cs file.
这是我的根元素看起来像的一个例子:
Here is an example of what my root element looks like:
<Base:BasePage x:TypeArguments="ViewModels:MyViewModel">
我很难找到有关Silverlight 4是否支持此方法的好信息.我们将不胜感激.谢谢!
I've had trouble finding good information on whether this is supported in Silverlight 4. Any help would be greatly appreciated. Thanks!
推荐答案
很遗憾,Silverlight还不支持.如果要在XAML中包括一个类,则该类不能是通用的.您仍然可以拥有一个泛型并将其从代码添加到可视树中,但不能直接在XAML中添加.
Unfortunately it isn't yet supported in Silverlight. If you want to include a class in XAML it can't be generic. You could still have a generic and add it to the Visual Tree from code, but not directly in the XAML.
这篇关于Silverlight 4对x:TypeArguments的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!