我该如何进行这项工作?
public partial class MyWindow : View<MyViewModel>
{
}
其中 View 定义为
public class View<T> : Window where T : IViewModel, new()
{
}
XAML:
<local:View
x:Class="Project.MyWindow"
x:TypeArguments="ViewModels:MyViewModel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:ViewModels="clr-namespace:Mynamespace.ViewModels;assembly=Mynamespace.ViewModels"
xmlns:local="clr-namespace:Project"
>
我收到此错误...名称 View 在名称空间 Project 中不存在...当然存在。
我得到这个错误,这真的让我感到困惑......“ http://schemas.microsoft.com/winfx/2006/xaml ”命名空间中不存在属性“TypeArguments” ......当然它确实存在。
关于如何在 wpf 中使用泛型作为 Windows 的基类的任何线索?