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
Post a Comment