xamarin - MvxViewController.PresentationAttribute called before ViewModel is loaded -
i have problem xamarin.ios , mvvmcross, need display mvxviewcontroller , comes in 2 ways depending on calls it, with:
customviewcontroller:
public partial class customviewcontroller : mvxviewcontroller<customviewmodel>, imvxoverridepresentationattribute { public customviewcontroller() : base("customviewcontroller", null) { } public mvxbasepresentationattribute presentationattribute() { if (viewmodel.kindnavigation) //here's issue { return new mvxsidebarpresentationattribute(mvxpanelenum.center, mvxpanelhinttype.resetroot, true, mvxsplitviewbehaviour.detail); } else { return new mvxmodalpresentationattribute { modalpresentationstyle = uimodalpresentationstyle.overfullscreen, modaltransitionstyle = uimodaltransitionstyle.coververtical }; } } } if viewmodel.anything, parameter define type of presentation, viewmodel, null , can't access. have not opened it, since type of presentation view not defined.
customviewmodel:
public class customviewmodel : mvxviewmodel<string>, idisposable { private readonly imvxnavigationservice _navigationservice; public customviewmodel(imvxnavigationservice navigationservice) { _navigationservice = navigationservice; } private bool _kindnavigation; public bool kindnavigation { => _kindnavigation; set => setproperty(ref _kindnavigation, value); } public void dispose() { throw new notimplementedexception(); } public override task initialize(string parameter) { kindnavigation = convert.toboolean(parameter); system.diagnostics.debug.writeline("parameter: " + parameter); return base.initialize(); } }
this restriction in mvvmcross, because viewmodel not loaded before view is. described in documentation: https://www.mvvmcross.com/documentation/platform/ios-view-presenter?scroll=731#override-a-presentation-attribute-at-runtime
Comments
Post a Comment