Page 1 of 1

Get user profile information

Posted: Wed May 02, 2012 12:07 am
by CodenStuff
The following will allow you to get and use the logged in users profile information for use in a metro app.

Get the users display name:
Code: Select all
Windows.System.UserProfile.UserInformation.DisplayName
Get the users first name:
Code: Select all
Windows.System.UserProfile.UserInformation.FirstName
Get the users last name:
Code: Select all
Windows.System.UserProfile.UserInformation.LastName
Get the users profile picture:
Code: Select all
Dim ProfilePicture As StorageFile = Windows.System.UserProfile.UserInformation.GetAccountPicture(Windows.System.UserProfile.AccountPictureKind.SmallImage)
        Dim PictureStream As IRandomAccessStream = Await ProfilePicture.OpenReadAsync()
        Dim BitmapImage As BitmapImage = New BitmapImage()
        BitmapImage.SetSource(PictureStream)
        ImageControl.Source = BitmapImage
Change "ImageControl" to the name of the control you wish to display the image inside. You can also change ".SmallImage" to ".LargeImage" to get a larger version of the profile picture.

Re: Get user profile information

Posted: Wed May 02, 2012 7:54 am
by Usman55
Can you tell us where you got all this info? I'm excited about it.

Re: Get user profile information

Posted: Wed May 02, 2012 8:42 am
by Dummy1912
:lol: nice

to bad i haven't win8
but i known you can do the same thingy in other windows.
okay maybe not the same 100% code but just enough
to get that part :)