Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: prism-unity how to passed data to viewmodel class

$
0
0
Hi everyone,

I have question on passed data to viewmodel.

I have controller base abstract class who provides virtual generic method:
        protected virtual void ActivateView<T>(string regionname, string viewname, object viewModelData = null)
        {
            var _view = this.RegionManager.Regions[regionname].GetView(viewname);
            if (_view == null)
            {
                _view = this.Container.Resolve<T>(viewname);
                this.RegionManager.Regions[regionname].Add(_view, viewname);
            }
// Before Activate View in region I must do it something to pass data to viewmodel :(
            this.RegionManager.Regions[regionname].Activate(_view);
        }
It is based class (methods) for all controllers who activates views in regions in my app.
ViewModel to active view is connected via a Dependency:
        public MyView()
        {
            InitializeComponent();
        }

        [Dependency]
        public ViewModel View_Model
        {
            get { return (View_Model)this.DataContext; }
            set { this.DataContext = value; }
        }
It works very fine but problem is when I will passed data to viemodel (who is related with view who is activated in region) via ActivateView<T>(...) method. In list of parameters is something like "object viewModelData" - this is it what I want pass to viewmodel linked with activated view.

I have not idea how do it :( Maybe somebody did have similar problem - please help me :)

Kind Regards,

Kri$

P.S. Sorry form my language still I learn it :)

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>