2017-07-26 30 views
2

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

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> 

错误我收到的是:

The name "InfoListViewBase`1" does not exist in the namespace "using:App.Views". 

错误每次我行x:TypeArguments="l:Model"添加到XAML时间显示出来。
在Visual Studio中进行多重重建,清理等操作并未解决问题。
有没有我在XAML中执行泛型的错误?

回答

2

不幸的是,UWP应用程序不支持XAML中的泛型参数。您目前不能在XAML中使用x:TypeArguments。但是您可以参考this thread尝试解决问题。

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

+1

听到这个很难过。感谢你的回答! – cloudcrypt