Windows 8应用商店对x:TypeArguments的支持 [英] Windows 8 Store Application Support for x:TypeArguments

查看:58
本文介绍了Windows 8应用商店对x:TypeArguments的支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道与此相同的东西: Silverlight 4对x:TypeArguments的支持 ...但适用于Windows 8 Store Apps.

I'd like to know the same thing as this: Silverlight 4 Support for x:TypeArguments ... but for Windows 8 Store Apps.

如果x:TypeArguments不起作用,为什么它可用?还是我错过了什么?即使在XAML中定义了x:TypeArguments,MainPage.i.g.cs文件仍会使用非通用基类自动生成-当然,它不会编译.

Why is x:TypeArguments available if it doesnt work? Or am I missing something? The MainPage.i.g.cs file is auto-generated with a non-generic base class even though x:TypeArguments is defined in the XAML - so of course it doesn't compile.

我可以使用建议的变通方法来工作,即拥有一个指定泛型类型的"typedef"基类,但是对我来说这很hacky..

I can get it working with the proposed work-around of having a "typedef" base class which specifies the generic type, but this feels pretty hacky to me..

// A generic PageBase, containing standard ViewModel-related utilities
internal abstract class PageBase<T> : Windows.UI.Xaml.Controls.Page where T : ViewModelBase
{
    protected abstract T ViewModel { get; }
    ...
}

// The hack...
internal abstract class MainPageTypeDef : PageBase<MainViewModel>
{
    // No code goes here...
}

// The page itself
internal sealed partial class MainPage : MainPageTypeDef
{
}

<views:PageBase
    ...
    x:Class="Namespace.MainView"
    x:TypeArguments="store:MainViewModel">

任何人都知道是否有一种不使用"typedef"类的方法吗?

Anyone know if there is a way of not having the "typedef" class?

非常感谢, 乔恩

推荐答案

很遗憾,这是不可能的.我从Microsoft联系人处得到了一个明确的答案:我可以确认,但Xaml中使用x:TypeArguments不受Windows Store Apps支持."

Sadly it's not possible. I got a definitive answer from a Microsoft contact: "I can confirm that but x:TypeArguments use in Xaml is not a supported scenario Windows Store Apps."

这篇关于Windows 8应用商店对x:TypeArguments的支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆