I’m a newbie in windows phone development, so excuse me if my question is a stupid one.
I’ve developed a simple generic class intended to be a base class for all the pages in my WP7 applicaion. Here it goes:
namespace Subway.Rails
{
public class Screen<TModel> : PhoneApplicationPage where TModel: class, new()
{
private static readonly DependencyProperty ModelProperty = DependencyProperty.Register("Model", typeof(TModel),
typeof (Screen<TModel>),
new PropertyMetadata(new TModel()));
public TModel Model
{
get { return GetValue(ModelProperty) as TModel; }
set { SetValue(ModelProperty, value); }
}
}
}
However when I am trying to declare a page in XAML using the x:TypeArguments directive
<rails:Screen x:TypeArguments="models:NotesStorage" xmlns:rails="clr-namespace:Subway.Rails;assembly=Subway.Rails" ...
and doubling the base type in the *.xaml.cs file
public partial class HomeView : Screen<NotesStorage>
I am getting a runtime error
Error 7 Using the generic type 'Subway.Rails.Screen<TModel>' requires 1 type arguments D:\development\labs\mobilelab\Subway.Notes\Subway.Notes\obj\Debug\Views\HomeView.g.cs 37 50 Subway.Notes
in the generated file.
Are there any ways to instantiate the generic page in XAML?
Although I couldn’t find anything stating it officially (it’s always hard to find documentation on unsupported features) in general: when it is not supported in Silverlight it isn’t available on Windows Phone.
The error messages you are seeing seem to confirm this.