问题
I am trying to learn using the Facebook SDK for .NET. Specifically for Windows Phone 8.1 Universal App (not Silverlight). For this I have build the 'LoginButton Control' sample that can be found here: http://facebooksdk.net/docs/windows/controls/login-ui-control/ I have sucessfully logged in to Facebook with the sample, but the 'Name' newer shows up. It is related to this part of the code:
<!--user information-->
<StackPanel HorizontalAlignment="Right">
<TextBlock
HorizontalAlignment="Center"
Text="{Binding CurrentUser.Name, ElementName=loginButton}" />
</StackPanel>
It seems that 'CurrentUser.x' is not able to retrieve other data like ID, Name etc. For further testing, I added the 'ProfilePicture Control' sample. It turns out that the profile picture shows fine, but all other GraphUser objects cannot be shown.
I am using Visual Studio 2013, Facebook 6.8.0, Facebook.Client 1.0.2.
Does anyone have an explanation for why this sample do not give access to GraphUser objects?
Best regards
回答1:
You are not alone!! I had the same problem you had but however I managed to get it done after spending 6 hours. The documentation of Nuget Facebook SDK seems outdated and not properly written. This Answer helped me a lot.
Here is the Xaml I used.`
<TextBlock x:Name="Ganesh" Grid.Row="0"
FontSize="72"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Welcome"
Foreground="Red"
Visibility="Collapsed"/>
<facebookControls:LoginButton
x:Name="loginButton"
Grid.Row="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
SessionStateChanged="loginButton_SessionStateChanged"/>
<facebookControls:ProfilePicture
x:Name="profilePicture"
Width="50"
Height="50"
VerticalAlignment="Center"
HorizontalAlignment="Center"
CropMode="Original"
Grid.Row="3"/>
<TextBlock x:Name="userInfo"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextWrapping="Wrap"
Text=""
FontSize="20"
Grid.Row="1"
Foreground="#FF8B2020"
Visibility="Collapsed"/>
`
And here is the Xaml.Cs
Include all necessary namespaces. This code was not neatly written. It was for test. Thanks.
来源:https://stackoverflow.com/questions/29367101/loginbutton-control-sample-for-facebook-sdk-for-net-do-not-show-graphuser-obj