ストアページに行く前にアプリケーションを作成してから、最初にログインする必要があります。最初にチェックしました。ログインすると、Storeページに直接ナビゲートできます。しかし、ログインしていなければ、ユーザーはログインしなければならず、ログインボタンをクリックすると、「ストア」ページにナビゲートされます。あなたは "Koleksi" ページにナビゲートしたい場合は同様にログイン後にナビゲートできない
XAML:
<Image x:Name="store" HorizontalAlignment="Center" Width="150" Height="150" Margin="20,0,0,0" VerticalAlignment="Center" Tapped="store_Tapped" Source="images/new icon/BSE-book-icon-store.png"/>
<Image x:Name="bukukoleksi" HorizontalAlignment="Center" Width="150" Height="150" Margin="20,0,0,0" VerticalAlignment="Center" Tapped="koleksi_Tapped" Source="images/new icon/bse-icon300-w8-KOLEKSI.png"/>
<callisto:CustomDialog x:FieldModifier="public" x:Name="LoginDialog"
Title="Login"
Background="#FFFCDAA2" BackButtonVisibility="Collapsed" Grid.Row="0" Grid.RowSpan="2">
<StackPanel x:Name="loginBox">
<TextBlock x:Name="spacerLogin" VerticalAlignment="Top" Style="{StaticResource TitleTextBlockStyle}" Width="300" Height="50" Text=""/>
<Grid x:Name="loginEnter">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="FailedMessage" FontSize="17" Text="Login failed!" Foreground="Red" Visibility="Collapsed" Grid.Row="0" Grid.ColumnSpan="2"/>
<TextBlock x:Name="email" Text="Email:" Grid.Column="0" Grid.Row="1" Margin="0,10,0,0" FontSize="18" Height="40" VerticalAlignment="Center" Foreground="#FFCA6402"/>
<TextBox x:Name="emailBox" PlaceholderText="Email" FontSize="17" Grid.Column="1" Grid.Row="1" Margin="10,10,0,0" Height="40" VerticalAlignment="Top"/>
<TextBlock x:Name="password" Text="Password:" Grid.Column="0" Grid.Row="2" FontSize="18" Height="40" Margin="0,10,0,0" VerticalAlignment="Center" Foreground="#FFCA6402"/>
<PasswordBox x:Name="passwordBox" Grid.Column="1" Grid.Row="2" PlaceholderText="Password" FontSize="18" Height="40" Margin="10,10,0,0"/>
<StackPanel Grid.Row="3" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Center">
<Button x:Name="loginBtn" Background="#FFCA6402" Content="Login" Margin="0,20,0,0" FontWeight="SemiBold" Click="loginBtn_Click" BorderBrush="Black" BorderThickness="1"/>
<Button x:Name="cancelLoginBtn" Background="#FFCA6402" Content="Batal" Margin="20,20,0,0" FontWeight="SemiBold" Click="cancelLoginBtn_Click" BorderBrush="Black" BorderThickness="1"/>
</StackPanel>
<ProgressRing x:Name="loadingLogin" Grid.RowSpan="4" Grid.ColumnSpan="2" Width="50" Height="50" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#FFCA6402" IsActive="False"/>
</Grid>
コード:
private void store_Tapped(object sender, TappedRoutedEventArgs e)
{
if (((App)(App.Current)).UserName == "Sign in to your account")
{
LoginDialog.IsOpen = true;
loginDetail.Visibility = Visibility.Collapsed;
loginEnter.Visibility = Visibility.Visible;
emailBox.Text = "";
passwordBox.Password = "";
}
else
{
this.Frame.Navigate(typeof(Store));
}
}
private void koleksi_Tapped(object sender, TappedRoutedEventArgs e)
{
if (((App)(App.Current)).UserName == "Sign in to your account")
{
LoginDialog.IsOpen = true;
loginDetail.Visibility = Visibility.Collapsed;
loginEnter.Visibility = Visibility.Visible;
emailBox.Text = "";
passwordBox.Password = "";
}
else
{
this.Frame.Navigate(typeof(koleksibuku.KolesiPage));
}
}
private void loginBtn_Click(object sender, RoutedEventArgs e)
{
loadingLogin.IsActive = true;
FailedMessage.Visibility = Visibility.Collapsed;
ProsesLogin();
}
private async void ProsesLogin()
{
FailedMessage.Visibility = Visibility.Collapsed;
loadingLogin.IsActive = true;
try
{
var filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter();
filter.ServerCredential = new Windows.Security.Credentials.PasswordCredential("BSE_Win10(1)", "mahonidatastream", "Maho1019");
var client = new Windows.Web.Http.HttpClient(filter);
string urlPath = "https://...m/user/auth";
var values = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("email", emailBox.Text),
new KeyValuePair<string, string>("password",passwordBox.Password)
};
var response = await client.PostAsync(new Uri(urlPath), new Windows.Web.Http.HttpFormUrlEncodedContent(values));
response.EnsureSuccessStatusCode();
if (!response.IsSuccessStatusCode)
{
//RequestException();
loadingLogin.IsActive = false;
}
string jsonText = await response.Content.ReadAsStringAsync();
JsonObject jsonObject = JsonObject.Parse(jsonText);
bool error = jsonObject["error"].GetBoolean();
//string message = jsonObject["message"].GetString();
if (error == false)
{
LoginDialog.IsOpen = false;
FailedMessage.Visibility = Visibility.Collapsed;
((App)(App.Current)).UserName = emailBox.Text;
loadingLogin.IsActive = false;
}
else
{
FailedMessage.Visibility = Visibility.Visible;
FailedMessage.Text = "Email atau password tidak sesuai/belum terdaftar";
loadingLogin.IsActive = false;
}
}
catch (HttpRequestException ex)
{
//ConnectionException();
loadingLogin.IsActive = false;
}
}
私は問題を抱えている、「いつタップ "ストア" またはその「bukukoleksi」と「loginBtn」をクリックした後は、「Store」ページまたは「Koleksi」ページに移動することはできません。 「店」と「Koleksi」ページに移動できるようにするには、再度「店」または「コール店」をタップする必要があります。 どのように処理するのですか?