Reputation: 9455
I'd like to know the same thing as this: Silverlight 4 Support for x:TypeArguments ... but for Windows 8 Store Apps.
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.
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">
Anyone know if there is a way of not having the "typedef" class?
Many thanks, Jon
Upvotes: 2
Views: 609
Reputation: 9455
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."
Upvotes: 3
Reputation: 1726
I'm pretty sure the answer is the same as for Silverlight. WinRT Xaml is in many ways closer to Silverlight Xaml than it is to WPF, and they've made all sorts of strange decisions in what to include and what not to.
Upvotes: 0