1

Ported my Xamarin iOS app to the unified api. I'm using MvvmCross and I can no longer bind to TextColor with a UITextView. I receive the following warning:

MvxBind:Warning: 39.30 Failed to create target binding for binding TextColor for EditableTextColour

My view:

set.Bind(userPromptTextView).For(up => up.BackgroundColor).To(vm => vm.EditableBackgroundColour);
set.Bind(userPromptTextView).For(up => up.TextColor).To(vm => vm.EditableTextColour);

ViewModel:

public UIKit.UIColor EditableTextColour
{
    get
    {
        return Question.IsEditable ? UIKit.UIColor.Black : UIKit.UIColor.Black.ColorWithAlpha(0.5f);
    }
}

Note that BackgroundColor binds correctly, although I believe that is binding to UIView.

I'm using MvvmCross 3.5.1-alpha1 and testing on an iPad (iOS 8.1.3).

NuGet packages

  <package id="MvvmCross" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.HotTuna.CrossCore" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.HotTuna.MvvmCrossLibraries" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.HotTuna.Plugin.Color" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.HotTuna.Plugin.Visibility" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.HotTuna.StarterPack" version="3.5.1-alpha1" targetFramework="xamarinios10" />
  <package id="MvvmCross.PortableSupport" version="3.5.1-alpha1" targetFramework="xamarinios10" />
AllDayer
  • 993
  • 1
  • 9
  • 20
  • Are there any additional warnings or log messages? Can you check you are using `MvvmCross 3.5.1-alpha1`? and how are you `testing on an Android device`? – Stuart Feb 19 '15 at 14:08
  • Sorry @Stuart I meant iPad. I've been doing a lot of Android work lately. I'm fairly certain I'm using 3.5.1-alpha1 (I've added NuGet packages above) although there are still references to 3.2.1 in my packages folder. My application builds a form dynamically so I isolated a page to only contain the above control and that is the only warning I get. I have a lot of other bindings and this is the only issue I have encountered. – AllDayer Feb 19 '15 at 22:40
  • So I had some references to 3.2.1 in another project which I have now updated. There are now no references to 3.2.1 at all. – AllDayer Feb 19 '15 at 22:59

1 Answers1

0

Maybe this will answer your question: https://github.com/MvvmCross/MvvmCross/issues/902

I had the same issue but with boolean-binding of a UILabel and UIView element. A simple workaround is to just declare the UI-Element as a private property in your class (in your case: userPromptTextView).

With this workaround, the GC won't eliminate your element and the binding should work.

Additional info: Is this a bug in MonoTouch GC?

Community
  • 1
  • 1
Joehl
  • 3,671
  • 3
  • 25
  • 53
  • 1
    Thanks for the suggestion but no luck there. Although you can't tell from my sample, `userPromptTextView` was a local variable which I moved to a private property of the view. I still receive the above warning. – AllDayer Feb 19 '15 at 22:48