Application Support for Windows 8 for x: TypeArguments

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

Why are x: TypeArguments available if it doesn't work? Or am I missing something? The MainPage.igcs file is automatically generated with a non-primary base class, although x: TypeArguments is defined in XAML - therefore, of course, it does not compile.

I can get it to work with the proposed workaround for having a "typedef" base class that defines a generic type, but that seems 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">

Does anyone know if there is a way to not have a typedef class?

Thanks a lot John

+1
2

, . Microsoft: " , x: TypeArguments Xaml Windows Store Apps".

+3

, , Silverlight. WinRT Xaml Silverlight Xaml, WPF, , .

0

Source: https://habr.com/ru/post/1614636/


All Articles