facebook-csharp-sdk / facebook-winclient-sdk

Facebook SDK for Windows & Windows Phone
http://facebooksdk.net
Apache License 2.0
61 stars 139 forks source link

LoginButton should support data binding / MVVM architecture #33

Open BobDickinson opened 11 years ago

BobDickinson commented 11 years ago

The general assumption here is that Win8 controls that consume or produce data should support data binding, and in the case of the LoginButton, which does both, it should support "TwoWay" data binding (for at least CurrentSession, and ideally CurrentUser as well).

See this "question" on StackOverflow: http://stackoverflow.com/questions/18269169/facebook-c-sharp-sdk-loginbutton-state-management

The LoginButton intentionally obscures/protects the CurrentSession and CurrentUser, making it very hard to integrate a LoginButton into an app of any complexity or sophistication (a "real" app) without some non-trivial code-behind. Ideally, these values should be exposed so they can be bound to a ViewModel (or equivalent) using TwoWay binding, allowing them to be initialized from app state (ViewModel) when a page is loaded, and allowing the ViewModel (or equivalent) to be automatically notified when they change (based on user interaction with the control).

The only way to do this right now, as far as I can tell, is to have a bunch of code-behind that initializes the values using SetValue on the button, and that responds to the session state changed and user changed events in the view, which is fairly creepy and certainly not in keeping with separation of concerns (MVVM, etc).

In a real world app where you are separating the view from the rest of the app logic (so, for example, your designers can work on the UX in Blend), you don't want any code that you don't absolutely need in the view code-behind, and you wouldn't need any of that if the LoginButton supported TwoWay data binding for these values.

sanjeevdwivedi commented 10 years ago

@BobDickinson Can you please provide a pull request for this?