- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 MVP - PRISM WPF 应用程序有一个 BaseView。现在出于某种原因,我们考虑将 _presenter 作为 BaseView 中的模板化字段。
之前我的 View xaml 表示为
<base:BaseView xamlns:base="clr address of the dll which had BaseView" >
</base:BaseView>
现在我已经更改了 BaseView
至BaseView<TPresenter>,
那么我该如何编写Xaml呢?
最佳答案
从 .NET 4 Framework
和 XAML 2009 开始您就可以做到这一点。请参阅Generics in XAML在 MSDN 上
例如:
<my:BusinessObject x:TypeArguments="x:String,x:Int32"/>
对于 .NET 3.5:
For XAML 2006 usage when specifically targeting WPF, x:Class must also be provided on the same element as x:TypeArguments, and that element must be the root element in a XAML document. The root element must map to a generic type with at least one type argument. An example is PageFunction.
Possible workarounds to support generic usages include defining a custom markup extension that can return generic types, or providing a wrapping class definition that derives from a generic type but flattens the generic constraint in its own class definition.
关于wpf - 如何在 XAML 中指定泛型类型参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7573712/
我是一名优秀的程序员,十分优秀!