Thursday, 8 August 2013

Multibinding between 2 usercontrols

Multibinding between 2 usercontrols

I have 2 usercontrols. Usercontrol 1: The menubar which has buttons like
Add, Edit, Delete, Save and Undo. Usercontrol 2: Is a screen where the
user can input text in textboxes and passwordboxes
But when I want to save I'm used to do the following when I only have 1
usercontrol which has the buttons and everything instead of the menubar
and the 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 now the elementname "txtPassword" and "txtRepeatPassword" don't exist
in that scope. This is my SaveCommand when I click the save button. It
receives those 2 parameters so I can check is the 2 passwords are the same
and stuff like 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 to solve this issue?

No comments:

Post a Comment