Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Binding Issues

$
0
0

Is anyone else having a problem with bindings using Xamarin Studio on OS X? It seems as though bindings between the binding context and the UI element aren't carrying data from binding to UI, but the reverse works. For example, if I type into a bound entry, the text populates the target binding, but if I change the binding, it doesn't refresh the UI with the new value. This only started happening a couple of weeks ago, but I didn't have time to deal with it then to figure out why it is happening. My current work around is to use Visual Studio in a virtual machine, using the OS X build host to do the building. When I do this, everything works as expected, it's only when using XS in OS X that I have the issue.

Here are the things I've tried to resolve the issue:

  • Updated all nuget packages to the latest version
  • Updated Xcode and related tools to the latest version
  • Uninstall and reinstall Xamarin Studio and iOS/Android packages

It happens on both Android and iOS projects, using an actual device or the emulator/simulator. Originally, I thought I had done something in my project, but creating a new project with barely anything to it exhibits the same behavior:

        public class App : Application
        {
            public App()
            {
                var label = new Label();
                label.BindingContext = this;
                label.Text = "Default Text";
                label.SetBinding(Label.TextProperty, "Text");

                var button = new Button ();
                button.Text = "Push Me";
                button.Clicked += (sender, e) => this.Text = DateTime.Now.ToString();

                // The root page of your application
                MainPage = new ContentPage
                {
                    BindingContext = this,
                    Content = new StackLayout
                    {
                        VerticalOptions = LayoutOptions.Center,
                        Children =
                        {
                            label,
                            button
                        }
                    }
                };

                this.Text = "test";
            }

            public string Text {get;set;}
        }

With this, I would expect the label to default to "test" and that tapping the button would display the current date and time, but with my current issue, the label is blank and tapping the button does nothing. If I change the Clicked handler on the button to set the text property on the label itself instead of what it is bound to, it works. If I take this same project and build it using Visual Studio or take it to another machine with Xamarin Studio, it builds and runs as I would expect it to.

My guess is something has happened with my installation, but I don't know where to look at this point since an uninstall and re-install did not fix the problem.


Viewing all articles
Browse latest Browse all 58056

Trending Articles