Forum Xamarin Xamarin.Forms

TwoWay Binding fails to fire in Windows 8.1 phone and Store app when using SwitchCell ! - Android OK

brucemcmillanbrucemcmillan GBMember
edited July 2015 in Xamarin.Forms


I have been seeing some strange behaviour with PCL based solutions using SwitchCells where the TwoWay Binding seems not to work in the Phone and Store 8.1 Apps.

I have a multi target project that is using MVVMlight and provides all that is needed by the calling clients.

I have a view - View Model - Model with a simple list bound to a collection of simple model items (text & Boolean Fields )

I have been pulling my hair out for days trying to figure out why the binding seemed never to fire. I have for sake of speed been using the windows store app as the test client. After much investigation and debugging I found that the View when loaded would call the View Model and then in turn the Model , firing off the get / set property setters. However when I then used the switchcell to update the boolean the setter would never fire. The same behaviour appeared when using the phone 8.1 app.

Being new to this the natural assumption is that your an idiot and your doing something wrong ( could still be the case ! )

Out of chance I tested the solution on my android device and surprise surprise i was stunned / pleased to see that the setter fired when the switch was changed. I then repeated the test on a silverlight phone project I created and that worked in the same emulator that the non silverlight app failed in.

I haven't had a chance to test the code on a IOS device as yet but i'm guessing that the app will work as designed.

So there's either a setting in the universal Apps that should be set to fire TwoWay updates to the underlying view model or there's a bug in the forms support for those version.

Anyone seen this / care to comment ??


  • brucemcmillanbrucemcmillan GBMember


    After a lot of trial and error I think it's down to the implementation by the Universal Store app of the forms

    I have created an app using the std PCL template then added a new project as per this Xamarin Tutorial on how to add universal apps

    For the other apps the binding works two way and updates the underlying data. I have tested on an android device and a IOS simulator.

    on all devices the initial page load does a get on the property of the item in the list

    When the switchcell is operated the normal apps in the solution update / fire the setter, , but the universal store app does not update the list view item when the switchcell if operated,

    I have attached a solution that demonstrates the behaviour. You'll need 7zip to extract it

    Is this a bug ???

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai
    edited July 2015

    Hey Bruce,

    It looks like the error was adding a Universal project rather than a separate Windows 8.1 app project and Windows Phone 8.1 app project. This is what is done in the guide you linked, so I think there was just a bit of confusion. I will see if the docs team can make it more clear in the guide not to use the Universal App project for the Windows app.

    I did verify that your two way bindings worked on both Windows 8.1 and Windows Phone 8.1 when using the separate projects instead of the Universal.

    Let us know if this resolves the issue for you too.

  • brucemcmillanbrucemcmillan GBMember


    Thanks for the note.

    I have, i believe, followed the route that you took..

    I removed the universal project.
    Cleaned the solution
    deleted all the bin / obj dirs in the solution
    added a new blank project, included the references, added the snippets as per the tutorial

    However :-( no success.

    The app will, as it did before, fire the getters when the UI is loading and when the test data is being created.

    However when the app is running, clicking the switch in the application ( windows 8.1 ) does not cause an update to fire in the DataItem.

    I have attached a copy of the updated solution.

    You mentioned that you had a working version of this. Could you please forward you working solution ?

    One other question, Are you using the MVVMlight libs as well or the std Xamarin ones ?


  • brucemcmillanbrucemcmillan GBMember


    I have also created a solution using just the std forms and removing the MVVMlight libraries from the solution

    The behaviour seems to be identical. The three std PCL apps work as expected but the newly added Win Blank App does not. It still fires the getters when loading the UI, but not when the switchcell is clicked in the windows app.

    Attached new solution.

    BTW I am using Win 10 / vs 2103 update 4 . I assuming that is not part of the problem ?

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    My Apologies, it seems I made an error. When I first loaded your project and ran the Windows app without any changes, no breakpoints were hit on app load or later. When I made the noted changes, the setter breakpoint was hit when the app loaded, but not later when clicking the switch controls. I am not sure why the breakpoints were not hit before I made the changes. Anyway, I misread the issue and thought it was that the setter was never called so when I saw it hit after the changes I thought, wrongly, that that was it. My apologies.

    I confirmed the described behavior using your new solution that does not use MVVMLight (thanks for that as it removes MVVMLight from the equation) and have filed a bug report which you can track here:

  • MartinPraxmarerMartinPraxmarer ATMember ✭✭

    Hi - just ran into the same Problem? Is this still not fixed?

  • MartinPraxmarerMartinPraxmarer ATMember ✭✭


  • rarenivarrarenivar USMember ✭✭

    I'm having the same issue on a Windows Phone 8.1 project, the binding for a SearchBar XAML element works on Android and iOS but not Windows Phone 8.1 (I'm using Xamarin 2.0.1).

  • MartinPraxmarerMartinPraxmarer ATMember ✭✭

    Why does such a simple thing does not get fixed?

  • Adittya.RaajAdittya.Raaj INMember

    Hi..Guys...I am able to resolve the problem with Onchange event of SwitchCell on Winphone 8.1, by updating the xamarin forms version to latest version.

Sign In or Register to comment.