0

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?

  • 1
    Please show the code you wrote that "works except ...". Its always easier to give a useful answer, if you show the exact code. Otherwise, its too easy to misunderstand exactly what you are trying to do. Specifically, is the property supposed to have type `MyContentPage`? Also, please show the line(s) of .g.cs that you manually change. – ToolmakerSteve Nov 03 '21 at 00:27
  • I found a similar answer (relates to forms, but works the same) [here](https://stackoverflow.com/questions/29349279/how-to-inherit-a-generic-form-and-open-it-in-the-visual-studio-designer): – Ido Dvir Nov 03 '21 at 20:46
  • To help you, I need to see exactly what code you tried. And what edit you had to make to the line(s) of .g.cs. – ToolmakerSteve Nov 03 '21 at 21:31

0 Answers0