c# - Using same x:Name in usercontrols with MVVM Light -


i use mvvm light in wpf-application. have usercontrol. passes element elementname commandparameter command.

<usercontrol> <i:interaction.triggers>         <i:eventtrigger eventname="loaded">             <cmd:eventtocommand command="{binding loadcommand}"     commandparameter="{binding elementname=image}"></cmd:eventtocommand>         </i:eventtrigger>     </i:interaction.triggers> <image name="image" /> </usercontrol> 

in mainview use usercontrols:

<window>   <l:mycontrol />   <l:mycontrol /> </window> 

viewmodel

 class mainviewmodel:viewmodelbase  {     public mainviewmodel()     {        loadcommand = new relaycommand<image>(onload);     }      private void onload(image image)     {        draw(image,bitmap);     }  } 

"draw" function writing on image usercontrol's parameters. cause images have same x:name, application draws on last image. how else can pass element command?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -