xamarin - Generic in custom page (XAML) -
i have issue xamarin , have found similar issue on xamarin forum. here is, enter link description here. didn't solution this. can me issue.
another forum link is: another xamarin forum link
-- update
here autogenerated code
namespace mydemo.app.views { using system; using xamarin.forms; using xamarin.forms.xaml; public partial class signinview : global::mydemo.app.views.baseview { [system.codedom.compiler.generatedcodeattribute("xamarin.forms.build.tasks.xamlg", "0.0.0.0")] private void initializecomponent() { this.loadfromxaml(typeof(signinview)); } } }
if understood correctly, suggest use:
public class somepage : somegenericpage<someviewmodel> { } public partial class someanotherpage : somepage { public someanotherpage() { initializecomponent(); } }
my somepage
has generic t
property viewmodel
, reach someanotherpage
. viewmodel
property have type someviewmodel
.
public class somegenericpage<t> : contentpage t : somebaseviewmodel, new() { readonly t _viewmodel; public t viewmodel => _viewmodel; public somegenericpage() { _viewmodel = new t(); bindingcontext = _viewmodel; } }
Comments
Post a Comment