UWP Windows 10 应用程序中页面/视图的通用基类

clo*_*ypt 5 c# wpf xaml uwp template10

在使用 Template10 的 UWP-Windows 10 C#/XAML 应用程序中,我目前正在尝试让我的页面/视图从继承自Windows.UI.Xaml.Controls.Page.
这一直正常工作,但是当我尝试使基类通用并以以下方式在子类和 XAML 中包含类型参数时,它不起作用:

namespace App.Views 
{
    public abstract class InfoListViewBase<M> : Page where M : InfoListViewModelBase
    {

        public InfoListViewBase() { }

    }

    public sealed partial class ModelPage : InfoListViewBase<Model>
    {
        public Model()
        {
            InitializeComponent();
            NavigationCacheMode = NavigationCacheMode.Disabled;
        }
    }
}

<local:InfoListViewBase 
    x:Class="App.Views.ModelPage"
    x:TypeArguments="l:Model"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Behaviors="using:Template10.Behaviors"
    xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:controls="using:Template10.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:App.Views"
    xmlns:l="using:Library"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

</local:InfoListViewBase>
Run Code Online (Sandbox Code Playgroud)

我收到的错误是:

The name "InfoListViewBase`1" does not exist in the namespace "using:App.Views".
Run Code Online (Sandbox Code Playgroud)

每次我将该行添加x:TypeArguments="l:Model"到 XAML时都会出现该错误。
在visual studio中多次重建、清理等都没有解决问题。
在 XAML 中实现泛型时我做错了什么吗?

Sun*_* Wu 6

不幸的是,UWP 应用程序仍然不支持 XAML 中的泛型参数。您x:TypeArguments目前无法在 XAML 中使用。但是您可以参考此线程以尝试解决方法。

如果您仍然需要此功能,您也可以将此功能请求提交给UserVoice