C# PasswordBox.SecurePassword在WinRT应用商店应用程序上不可用

C# PasswordBox.SecurePassword在WinRT应用商店应用程序上不可用,c#,wpf,windows-runtime,C#,Wpf,Windows Runtime,我正在为Windows 8.1、C和.NET Framework 4.5.1开发一个Windows应用商店应用程序 我正在尝试使用,但它似乎不可用。我已将框架版本更改为4.5,我已尝试使用.NETFramework 4.5.1的WPF测试项目,但它不可用 我已尝试将PresentationFramework.dll程序集添加到我的Windows 8.1应用商店应用程序中,但无法 我正在尝试这样做: { PasswordBox pass = new PasswordBox(); p

我正在为Windows 8.1、C和.NET Framework 4.5.1开发一个Windows应用商店应用程序

我正在尝试使用,但它似乎不可用。我已将框架版本更改为4.5,我已尝试使用.NETFramework 4.5.1的WPF测试项目,但它不可用

我已尝试将PresentationFramework.dll程序集添加到我的Windows 8.1应用商店应用程序中,但无法

我正在尝试这样做:

{
    PasswordBox pass = new PasswordBox();
    pass.SecurePassword // I'm checking if it is available
}
检查SecurePassword是否存在,但SecurePassword在Windows应用商店应用程序上不可用


Windows应用商店应用程序上是否有SecurePassword?

我担心Windows应用商店应用程序无法使用SecureString 您应该使用Windows.Security.Credentials的方法和对象

2007年10月夜间日本时间改写 我想你希望做像登录一样的工作,不是吗? 在这种情况下,Windows.Security.Credentials命名空间是一个简单的解决方案

请看上面的代码

cs文件

//MainPage.xaml.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Security.Credentials;

namespace App1
{

public sealed partial class MainPage : Page
{
    PasswordVault vault = new PasswordVault();

    public MainPage()
    {
        this.InitializeComponent();
        this.NavigationCacheMode = NavigationCacheMode.Required;

        //Initialize Credential data
        try
        {
            var alldata = vault.FindAllByResource("My List");
            foreach (PasswordCredential data in alldata)
            {
                vault.Remove(data);
            }
        }
        catch { }
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        //Certificate for Input data
        PasswordCredential credential = null;
        try
        {
            credential = vault.Retrieve("My List", Username.Text);

            if(credential.Password==password.Password)             
            {
                Status.Text = "Status : Succeed in Certificating";
            }
            else
            {
                Status.Text = "Status : Failed to Certification";
            }
        }
        catch { Status.Text = "Status : Failed to Certification"; }
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        //Registar on Input data
        try
        {
            vault.Add(new PasswordCredential("My List", Username.Text, password.Password));
            Status.Text = "Status : Succeed in Registering";
        }
        catch
        {
            Status.Text = "Status : Failed to Register";
        }
    }
}
}
xaml文件

<Page>

    <!-- MainPage.xaml -->
    <Grid>
        <PasswordBox Name="password"  HorizontalAlignment="Left" Height="118" Margin="531,197,0,0" VerticalAlignment="Top" Width="464" FontSize="52"/>
        <TextBox Name="Username" HorizontalAlignment="Left" Height="118" Margin="531,44,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="464" FontSize="52"/>
        <TextBlock HorizontalAlignment="Left" Height="118" Margin="10,44,0,0" TextWrapping="Wrap" Text="UserName" VerticalAlignment="Top" Width="505" FontSize="80"/>
        <TextBlock HorizontalAlignment="Left" Height="120" Margin="10,195,0,0" TextWrapping="Wrap" Text="PassWord" VerticalAlignment="Top" Width="505" FontSize="80"/>
        <TextBlock Name="Status" HorizontalAlignment="Left" Height="111" Margin="10,327,0,0" TextWrapping="Wrap" Text="Status " VerticalAlignment="Top" Width="1329" FontSize="60"/>

        <Button Content="Certification" HorizontalAlignment="Left" Height="124" Margin="1006,41,0,0" VerticalAlignment="Top" Width="336" Click="Button_Click" FontSize="52"/>

        <Button Content="Registration" HorizontalAlignment="Left" Height="124" Margin="1006,194,0,0" VerticalAlignment="Top" Width="336" Click="Button_Click_1" FontSize="52"/>

    </Grid>
</Page>

谢谢你的回答,但我不明白。是否有一个名为Windows.Security.Credentials的XAML控件?再次感谢您的回答,但我不是英国人或美国人,我不明白这句话中登录的含义:我想您希望像登录一样工作,不是吗?谢谢。而且我不是以英语为母语的人。我是日本人。在日本,认证任务通常称为登录任务。很抱歉让你产生误解
//data is a PasswordCredential value

//get Username
string username = data.UserName;
//get Password
string password = data.Password