Pregunta

I'm trying to have a login page for my app, jus like the windows login account. But this is not a account sign in. Once the user sets a password, every time the user opens the app afresh, it asks for the password.

From this site, I got how to create the login page. But the problem im facing is, once i put the grid inside the ContentControl it does not expand.

I had to specify the height and width of the grid named mainbackground. I do not want to hard code the values because as the resolution changes the height and width may vary.

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush  }">        
    <Grid.RowDefinitions>           
        <RowDefinition/>          
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions> 

    <ContentControl x:Name="parent" Grid.Row="0" Grid.RowSpan="1">
          <Grid x:Name="MainBackground" Height="768" Width="1366">
              <!-- rest of the xaml declaration-->
          </Grid>
    </ContentControl>

    <ContentControl  x:Name="container"  Height="450" Margin="0,194,0,124">
          <Popup x:Name="logincontrol1" IsOpen="False" >
    </ContentControl>
</Grid>

Few questions, Is this the correct method to create login page?

Why doesn't the grid expand to the who screen without me having to specify the height and width?

What is the actual use of content control? Didnt find elaborate explanations online.

Thank you

¿Fue útil?

Solución

The advice is not to write your own login page, but to use the CredentialPicker control.

In your case, you are not hooking the picker into anything, and that is a valid scenario. Set the picker options up like this...

CredentialPickerOptions opts = new CredentialPickerOptions {
    AuthenticationProtocol = AuthenticationProtocol.Basic,
    Caption = "My App Login",
    Message = "Log in here",
    TargetName = "MyApp"
    };
var res = await CredentialPicker.PickAsync(opts);

and then you can access the CredentialUserName and CredentialPassword values for your own logic.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top