c# - Multibinding between 2 usercontrols -


i have 2 usercontrols. usercontrol 1: menubar has buttons add, edit, delete, save , undo. usercontrol 2: screen user can input text in textboxes , passwordboxes

but when want save i'm used following when have 1 usercontrol has buttons , instead of menubar , detailscreen seperated:

     <button style="{dynamicresource savebutton}" command="{binding path=savecommand}">                 <button.commandparameter>                     <multibinding converter="{staticresource pwconverter}">                         <binding elementname="txtpassword" />                         <binding elementname="txtrepeatpassword" />                     </multibinding>                 </button.commandparameter>             </button> 

but elementname "txtpassword" , "txtrepeatpassword" don't exist in scope. savecommand when click save button. receives 2 parameters can check 2 passwords same , stuff that.

    private void saveuserexecute(object passwords)     {         try         {             var passwordvalues       = (object[])passwords;             passwordbox passwordbox1 = (passwordbox)passwordvalues[0];             passwordbox passwordbox2 = (passwordbox)passwordvalues[1];        ... 

any ideas on how solve issue?

because 2 usercontrols shared same datacontext i've made 2 properties represent passwordboxes. when initialize view did following:

    public inputuserview()     {         initializecomponent();         this.datacontext = inputuserviewmodel.instance;         inputuserviewmodel.instance.passwordbox1 = txtpassword;         inputuserviewmodel.instance.passwordbox2 = txtrepeatpassword;     } 

so viewmodel has knowledge of 2 passwordboxes. think it's not good, works me , can live


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -