Recommand · November 3, 2021 0

xamarin forms page inherits from generic class

I have several Xamarin forms that inherit from the same base class (which in turn inherits from ContentPage). I want the base class (MyBaseContentPage) to be a generic class so I can have a property set by each derived class to the correct type:

public class MyBaseContentPage : ContentPage …
public partial class MyContentPage: MyBaseContentPage …

This works except that I need to define the same type in the auto-generated partial class (the g.cs file) for each page, and every time I change something in the XAML file, it rewrites the g.cs file and I need to reapply the manual changes.
Is there a way to work around it?