Mvvmcross: UITextview binding - missing source event info in MvxWeakEventSubscription Parameter name: sourceEventInfo

Created on 17 Jan 2018  路  5Comments  路  Source: MvvmCross/MvvmCross

I still get an exception when I try to create a binding for the Text property on the UITextView.
If I remove the Line set.Bind(this.MessageTextView).To(vm => vm.Message); everything works.

Steps to reproduce :scroll:

1.Create a view with a UITextView on it.

2.Create a binding for the Text property on the UITextView

var set = this.CreateBindingSet<ContactView, ContactViewModel>();

set.Bind(this.NameTextField).To(vm => vm.Name);
set.Bind(this.FirstNameTextField).To(vm => vm.Firstname);
set.Bind(this.EmailTextField).To(vm => vm.Email);
set.Bind(this.MessageTextView).To(vm => vm.Message);
set.Bind(this.SendButton).To(vm => vm.SendFeedbackCommand);

set.Apply();

LinkerPleaseInclude:

...
        public void Include(UITextView textView)
        {
            textView.Text = textView.Text + "";            
            textView.Changed += (sender, args) => { textView.Text = ""; };            
        } 
...

3.Exception will happen as soon as Apply() is being called

Expected behavior :thinking:

View should be presented with TextView in it, and RaisePropertyChanged is triggered every time a character is typed.

Actual behavior :bug:

Fatal exception as soon as the view is about to be presented.
Error:
missing source event info in MvxWeakEventSubscription
Parameter name: sourceEventInfo

Stacktrace:
at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.Reflection.EventInfo sourceEventInfo, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00017] in <6adc0d5857264558a9d45778a78ae02a>:0 at MvvmCross.Platform.WeakSubscription.MvxWeakEventSubscription`2[TSource,TEventArgs]..ctor (UIKit.NSTextStorage source, System.String sourceEventName, System.EventHandler`1[TEventArgs] targetEventHandler) [0x00012] in <6adc0d5857264558a9d45778a78ae02a>:0 at MvvmCross.Platform.WeakSubscription.MvxWeakSubscriptionExtensionMethods.WeakSubscribe[TSource,TEventArgs] (TSource source, System.String eventName, System.EventHandler`1[TEventArgs] eventHandler) [0x00000] in <6adc0d5857264558a9d45778a78ae02a>:0 at MvvmCross.Binding.iOS.Target.MvxUITextViewTextTargetBinding.SubscribeToEvents () [0x00053] in C:\projects\mvvmcross\MvvmCross\Binding\iOS\Target\MvxUITextViewTextTargetBinding.cs:56 at MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (System.Object target) [0x00057] in C:\projects\mvvmcross\MvvmCross\Core\Binding\Bindings\MvxFullBinding.cs:160 at MvvmCross.Binding.Bindings.MvxFullBinding..ctor (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00028] in C:\projects\mvvmcross\MvvmCross\Core\Binding\Bindings\MvxFullBinding.cs:63 at MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (MvvmCross.Binding.MvxBindingRequest bindingRequest) [0x00000] in C:\projects\mvvmcross\MvvmCross\Core\Binding\Binders\MvxFromTextBinder.cs:55 at MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass2_0.<Bind>b__0 (MvvmCross.Binding.Bindings.MvxBindingDescription description) [0x00000] in C:\projects\mvvmcross\MvvmCross\Core\Binding\Binders\MvxFromTextBinder.cs:37 at System.Linq.Enumerable+SelectArrayIterator`2[TSource,TResult].MoveNext () [0x0003a] in <3ccacafc6c3a44509d2050a54b68cc48>:0 at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindings, System.Object clearKey) [0x0001d] in C:\projects\mvvmcross\MvvmCross\Core\Binding\BindingContext\MvxBindingContextOwnerExtensions.cs:65 at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, System.Collections.Generic.IEnumerable`1[T] bindingDescriptions, System.Object clearKey) [0x00018] in C:\projects\mvvmcross\MvvmCross\Core\Binding\BindingContext\MvxBindingContextOwnerExtensions.cs:86 at MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (MvvmCross.Binding.BindingContext.IMvxBindingContextOwner view, System.Object target, MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x0000b] in C:\projects\mvvmcross\MvvmCross\Core\Binding\BindingContext\MvxBindingContextOwnerExtensions.cs:79 at MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription`1[TTarget].Apply () [0x0001f] in <866b1e46764b48aab0d408952a6f006f>:0 at MvvmCross.Binding.BindingContext.MvxFluentBindingDescriptionSet`2[TOwningTarget,TSource].Apply () [0x00016] in <866b1e46764b48aab0d408952a6f006f>:0

Configuration :wrench:

Version:
5.6.3

Platform:

  • [ X] :iphone: iOS
  • [ ] :robot: Android
  • [ ] :checkered_flag: WPF
  • [ ] :earth_americas: UWP
  • [ ] :apple: MacOS
  • [ ] :tv: tvOS
  • [ ] :monkey: Xamarin.Forms
ios deprecated bug

Most helpful comment

You will need to add

textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";

to your LinkerPleaseInclude

All 5 comments

You will need to add

textView.TextStorage.DidProcessEditing += (sender, e) => textView.Text = "";

to your LinkerPleaseInclude

Thanks @Plac3hold3r! You've solved my problem.

@kenigj @Plac3hold3r Thanks guys!

This was added to the nuspec content here #2481.

The fix suggested by @Plac3hold3r did not work for me. But I am using the XamarinSidebar which contains the LinkerPleaseInclude. Would this be causing the problem? Because I only modified the LinkerPleaseInclude on my iOS app as the XamarinSidebar one is installed as a nuget package

Was this page helpful?
0 / 5 - 0 ratings