Is it possible to instantiate generic types in XAML for Windows Store App?
For example, I have page base class:
public class PageBase<T> : Page
{
}
How to create page of type PageBase<string> in XAML?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it’s not possible out of the box.
You can try a workaround (for example here), but from personal experience, I wouldn’t recommend it, things get messy really fast. We’ve tried to implement the above solution, but it turned out that it is easier to revise the design than handling generics from XAML.
In your case, I would recommend created derived classes from your base page using a specific type.