Search code examples
c#xamluwpxbind

Pass parameter to xbind event handler


In a WPF application, I had a login command that accepted a SecureString as a parameter. I used a xaml converter to pass the value from a password box to the command.

<PasswordBox
        Name="PasswordBox"
        Grid.Row="2"
        Grid.Column="2" />

    <Button
        Grid.Row="3"
        Grid.Column="3"
        Command="{Binding LoginCommand}"
        Content="{x:Static p:Resources.LoginView_LoginButtonContent}">
        <Button.CommandParameter>
            <MultiBinding
                Converter="{c:PasswordBoxConverter}"
                Mode="TwoWay"
                UpdateSourceTrigger="PropertyChanged">
                <Binding ElementName="PasswordBox" />
            </MultiBinding>
        </Button.CommandParameter>
    </Button>

I would like to do something similar in UWP using xbind. Can you pass parameters to an event handler with xbind?


Solution

  • UWP apps does not support Multibinding and you can not pass the event handler with xbind. Bind is for strong typed objects you will need to find another way to do that.

    With UWP you can do a Binding directly to the Password Property of the control in WPF is not possible.

    like this:

       <PasswordBox
                        Margin="0,12,0,0"
                        Header="Contraseña"
                        Password="{Binding Password, Mode=TwoWay}"
                        PasswordRevealMode="Peek"
                        PlaceholderText="Escribe tu contraseña" />
    

    Best Regards