Hi all,
This is driving me nuts. I'm trying to inherit from a base SettingsPage, and it's not working, and I can't find a single example anywhere of how to do it. All the examples I've found involve inheriting viewmodels, and other non-visual elements. In particular I'm not sure what you do with the "Content=" in the derived page, since the base page already sets "Content=". The MS doco on inheritance says that you don't inherit the constructor, but you can inherit from it using :base().
I've put together a colour-scheme picker (which extends on amporis.xamarin.forms.colorpicker), which I want to use as my base for other settings pages (in apps where I need other settings in addition to colour-scheme). I have a class library CSettings, for which CSettingsPage loads fine if loaded directly (which includes Content=SettingsGrid, which everything is loaded into to begin with) - everything is "public". I then have a TestBed app, and trying to create a TBSettingsPage. At the top I have
namespace TestBed { public class TBSettingsPage : CSettingsPage {...
(and I've referenced the DLL of course), and I've tried the following 3 variations with the constructor...
public TBSettingsPage():base() {}
public TBSettingsPage():base() { Content=SettingsGrid; }
public TBSettingsPage() { Content=SettingsGrid; }
Every time I get...
"Exception thrown: 'System.Runtime.InteropServices.COMException' in Xamarin.Forms.Platform.UAP.dll Error HRESULT E_FAIL has been returned from a call to a COM component." at the Xamarin.Forms init.
...which isn't a very helpful error message. It basically says "that's not right" without telling me what's not right nor how to fix it (Googling it comes up with a whole variety of situations, none of which apply to what I'm trying to do). :-(
Can anyone tell me how to derive from a BasePage that has view in it already? (I saw a tip about making it not visible until the page has been constructed, then make it visible, but that didn't help). Or point me to an example somewhere which implements such a thing?
Note: my UI is in C#, not XAML. Also this is in UWP, if that's relevant.
thanks,
Donald.