Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks
kenigj opened this issue Jan 17, 2018 · 5 comments
Labels
p/ios iOS platform s/deprecated Deprecated status t/bug Bug type
Milestone

Comments

@kenigj
Copy link

kenigj commented Jan 17, 2018

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 📜

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 🤔

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

Actual behavior 🐛

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 🔧

Version:
5.6.3

Platform:

  • [ X] 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms
@Plac3hold3r
Copy link
Contributor

You will need to add

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

to your LinkerPleaseInclude

@kenigj
Copy link
Author

kenigj commented Jan 18, 2018

Thanks @Plac3hold3r! You've solved my problem.

@andreipro1002
Copy link

@kenigj @Plac3hold3r Thanks guys!

@nmilcoff
Copy link
Contributor

This was added to the nuspec content here #2481.

@nmilcoff nmilcoff added t/bug Bug type s/deprecated Deprecated status p/ios iOS platform labels Jan 18, 2018
@nunohorta
Copy link

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

@martijn00 martijn00 added this to the 6.0.0 milestone Feb 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/ios iOS platform s/deprecated Deprecated status t/bug Bug type
Development

No branches or pull requests

6 participants