Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

How to have parameters like Navigation,id to BaseContentPage #37

Closed
avinash-ramireddy opened this issue Jul 27, 2017 · 0 comments
Closed

Comments

@avinash-ramireddy
Copy link

avinash-ramireddy commented Jul 27, 2017

I have few parameters like Navigation,id, name,somefunction() etc ..to pass for MyPageViewModel .

  1. But for now I am stuck(more like doubt) at passing Navigation as parameter. (added directly in basecontentpage.... didn't check the functionality yet)
  2. Also I need to pass id,name etc.. which I think I can do
  3. I also have a method in MyPageViewModel to be passed to BaseContentPage.

I am trying something like below

public class BaseContentPage <T> : MainContentPage where T : BaseViewModel 
    {
        protected object[] args;
        protected T viewModel;

        public T ViewModel => viewModel ?? (viewModel = Activator.CreateInstance(typeof(T), new object[] { Navigation,args }) as T);

        public BaseContentPage (params object[] args)
        {
            this.args = args;

            BindingContext = ViewModel;
        }

        ~BaseContentPage ()
        {
            viewModel = null;
            args = null;
        }
    }

Any help in above mentioned problems would be much appreciated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant