Windows 8 Store Apps學習(58) 微軟帳號

來源:互聯網
上載者:User

介紹

重新想象 Windows 8 Store Apps 之 微軟帳號

擷取微軟帳號的使用者相關的資訊

擷取或設定微軟帳號的圖片和視頻

微軟帳號的驗證,和相關資訊的擷取

 

樣本

1、示範如何擷取微軟帳號的使用者相關的資訊

Account/AccountInfo.xaml

<Page    x:Class="XamlDemo.Account.AccountInfo"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:local="using:XamlDemo.Account"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d">        <Grid Background="Transparent">        <StackPanel Margin="120 0 0 0">                <TextBlock Name="lblMsg" FontSize="14.667" />            </StackPanel>    </Grid></Page>

Account/AccountInfo.xaml.cs

/* * 示範如何擷取微軟帳號的使用者相關的資訊 */    using System;using Windows.System.UserProfile;using Windows.UI.Xaml.Controls;using Windows.UI.Xaml.Navigation;    namespace XamlDemo.Account{    public sealed partial class AccountInfo : Page    {        public AccountInfo()        {            this.InitializeComponent();        }            protected async override void OnNavigatedTo(NavigationEventArgs e)        {            if (UserInformation.NameAccessAllowed) // 是否允許訪問使用者名稱            {                // 擷取用於顯示的名稱                lblMsg.Text = "display name: " + await UserInformation.GetDisplayNameAsync();                lblMsg.Text += Environment.NewLine;                    // 擷取 first name                lblMsg.Text += "first name: " + await UserInformation.GetFirstNameAsync();                lblMsg.Text += Environment.NewLine;                    // 擷取 last name                lblMsg.Text += "last name: " + await UserInformation.GetLastNameAsync();                lblMsg.Text += Environment.NewLine;            }                // 如果需要擷取 GetDomainNameAsync(), GetPrincipalNameAsync(), GetSessionInitiationProtocolUriAsync() 等資訊            // 則需要在 Package.appxmanifest 中增加配置 <Capability Name="enterpriseAuthentication" />,且必須使用公司帳號上傳 app        }    }}

2、示範如何擷取或設定微軟帳號的圖片和視頻

Account/AccountPicture.xaml

<Page    x:Class="XamlDemo.Account.AccountPicture"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:local="using:XamlDemo.Account"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d">        <Grid Background="Transparent">        <StackPanel Margin="120 0 0 0">                <StackPanel Orientation="Horizontal">                <Button x:Name="btnSetImage" Content="設定當前微軟帳號的圖片(可以分別指定小圖,大圖,視頻)" Click="btnSetImage_Click_1" />            </StackPanel>                <StackPanel Orientation="Horizontal" Margin="0 10 0 0">                <Image x:Name="imgSmall" Width="96" Height="96" HorizontalAlignment="Left" />                <Image x:Name="imgLarge" Width="448" Height="448" Margin="10 0 0 0" HorizontalAlignment="Left" />                <MediaElement x:Name="mediaElement" Width="200" Height="200" Margin="10 0 0 0" HorizontalAlignment="Left" />            </StackPanel>            </StackPanel>    </Grid></Page>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.