Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

PasswordBox and text input problems RSS

5 replies

Last post Mar 03, 2009 01:26 PM by Ozanges

(0)
  • robert.oh.

    robert.oh.

    0 Points

    3 Posts

    PasswordBox and text input problems

    Dec 11, 2008 01:56 PM | LINK

    Hi,

    I have a Silverlight app that requires the user to log into the system, therefore I have a TextBox for the username, a PasswordBox for the password (what else ;-)) and a Button to log in.

    When the user clicks on the Button I set the TextBox's + PasswordBox's IsEnabled property to false and when the login process is done I reset this property to true again.

    The problem is that when the login doesn't succeed the user would have to reenter his credentials but that's not possible anymore - the cursor blinks inside the PasswordBox but you can't enter any text into it or anything else. It just seems like this control is somewhere overlayed by another control which isn't the case here as it is hosted inside a StackPanel.

    Any ideas what could be going on here and how to fix it?

    Thanks,

    robert.oh.

    -- robert.oh. --
  • hmaprk

    hmaprk

    Member

    175 Points

    77 Posts

    Re: PasswordBox and text input problems

    Dec 15, 2008 09:19 PM | LINK

    Could you post some of your xaml and code behind? That would help.

    hmaprk
    http://dotnetgui.blogspot.com/

    -Please mark As Answer if this answers your question. Thanks
  • robert.oh.

    robert.oh.

    0 Points

    3 Posts

    Re: PasswordBox and text input problems

    Dec 15, 2008 09:40 PM | LINK

    Good evening,

    here's the code:

     

    <UserControl x:Class="LogOnOffControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="blablabla" FontWeight="Bold"/>
            <TextBlock x:Name="lblErrorMessage" Grid.Column="1" Foreground="Red" FontWeight="Bold" Visibility="Collapsed" HorizontalAlignment="Right" TextWrapping="Wrap"/>
            <StackPanel x:Name="pnlLogOn" Orientation="Horizontal" Grid.Column="2">
                <TextBlock Text="Benutzername:"/>
                <TextBox x:Name="txtUserName" Width="60" Margin="5,0,5,0"/>
                <TextBlock Text="Passwort:"/>
                <PasswordBox x:Name="txtPassword" Width="60" Margin="5,0,5,0"/>
                <Button x:Name="btnLogOn" Content="Anmelden" Click="btnLogOn_Click" Margin="5,0,5,0"/>
            </StackPanel>
            <StackPanel x:Name="pnlLogOff" Orientation="Horizontal" Visibility="Collapsed" Grid.Column="2">
                <TextBlock Text="Angemeldet als "/>
                <TextBlock x:Name="lblUserName" Foreground="Red" FontWeight="Bold" Margin="5,0,5,0"/>
                <Button x:Name="btnLogOff" Content="Abmelden" Click="btnLogOff_Click" Margin="5,0,5,0"/>
            </StackPanel>
        </Grid>
    </UserControl>
     

    The click on 'btnLogon' calls the method below with a parameter value of 'false' to disable the controls and also calls the async WCF service that verifies the given credentials.

    In the 'Completed' part of the async WCF service the method below is called again with a parameter value of 'true'.

     

    private void SetLogOnComponentents(bool enableControls)
    {
        this.txtPassword.IsEnabled =
            this.txtUserName.IsEnabled =
            this.btnLogOn.IsEnabled = enableControls;
    }
     

    Hope this helps.

    Thanks for advice!

    -- robert.oh. --
  • FuryDiamond

    FuryDiamond

    All-Star

    23879 Points

    4072 Posts

    Re: Re: PasswordBox and text input problems

    Dec 15, 2008 10:19 PM | LINK

    Some of the XAML code is cut off. When the WCF fails, do you have it calling the SetLogOn function?

    Please "Mark as Answer" if this post answered your question. :)

    Silverlight 5 3D Tutorials: http://silverlight.bayprince.com
    Blog: http://blog.bayprince.com
    Twitter: http://twitter.com/bayprince
  • robert.oh.

    robert.oh.

    0 Points

    3 Posts

    Re: Re: PasswordBox and text input problems

    Dec 16, 2008 06:57 AM | LINK

    Good morning,

    I can't see cut off XAML code.

    But yes, if the service fails I'm also calling the method that enables the controls again.

    Thanks,

    robert.oh.

    -- robert.oh. --
  • Ozanges

    Ozanges

    Member

    29 Points

    26 Posts

    Re: Re: PasswordBox and text input problems

    Mar 03, 2009 01:26 PM | LINK

    Is there anybody who's found a workaround ? I have the same problem, and i have not finded a better practice than add a panel over textbox.