wpf - Reference the View from ViewModel while using DataTemplate for the ViewModel -


i'm using datatemplate provide association of view viewmodel, example:

<datatemplate datatype="{x:type viewmodels:someviewmodel}">     <views:someview /> </datatemplate> 

now need reference view somehow in viewmodel, reference control directly name. there anyway that?

  • note tried add someview parameter someviewmodel ctor someview ctor being invoked twice(one instance sent someviewmodel ctor , because of framework guess...)

thanks help

maybe you're looking for:

public partial class someview : usercontrol {     public someview()     {         initializecomponent();         this.loaded += view_loaded;     }      void someview_loaded(object sender, routedeventargs e)     {         var someviewmodel = (someviewmodel)this.datacontext;         someviewmodel.view = this;     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -