Get user profile information
Posted: Wed May 02, 2012 12:07 am
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:
Get the users display name:
Code: Select all
Get the users first name:Windows.System.UserProfile.UserInformation.DisplayName
Code: Select all
Get the users last name:Windows.System.UserProfile.UserInformation.FirstName
Code: Select all
Get the users profile picture:Windows.System.UserProfile.UserInformation.LastName
Code: Select all
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.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