Closed jijithvasudevan closed 5 years ago
Fixed in nuget package JV.XamForms.Controls.Calendar
Thanks for the fix. Had the same issue.
Yeah all that's needed to fix this issue is to check to see if the Control attribute is null in the OnElementPropertyChanged function in the CaeldnarButtonRender. So this:
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
var element = Element as CalendarButton;
if (Control != null)
{
if (e.PropertyName == nameof(element.TextWithoutMeasure) || e.PropertyName == "Renderer")
{
Control.SetTitle(element.TextWithoutMeasure, UIControlState.Normal);
Control.SetTitle(element.TextWithoutMeasure, UIControlState.Disabled);
}
if (e.PropertyName == nameof(element.TextColor) || e.PropertyName == "Renderer")
{
Control.SetTitleColor(element.TextColor.ToUIColor(), UIControlState.Disabled);
Control.SetTitleColor(element.TextColor.ToUIColor(), UIControlState.Normal);
}
if (e.PropertyName == nameof(element.BackgroundPattern))
{
DrawBackgroundPattern();
}
if (e.PropertyName == nameof(element.BackgroundImage))
{
DrawBackgroundImage();
}
}
}
It's also fixed in XamForms.Enhanced.Calendar ver. 1.2.1 which is a fork of this repository but updated. If it doesn't work, please raise an issue here
Good luck! 🚀
Has anyone faced this issue?
System.NullReferenceException with iOS for Calendar when used with Xamarin forms 4.0 Crash is here : Control.SetTitle(element.TextWithoutMeasure, UIControlState.Normal)
Stack Trace at XamForms.Controls.iOS.CalendarButtonRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00040] in /Users/jijithvasudevan/Downloads/XamForms.Controls.Calendar-master/XamForms.Controls.Calendar.iOS/CalendarButtonRenderer.cs:27 at (wrapper delegate-invoke).invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:211
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle, System.Boolean checkAccess) [0x000c6] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:78
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:30
at Xamarin.Forms.Platform.iOS.VisualElementRenderer:0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.Dispose (System.Boolean disposing) [0x00064] in :0
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in :0
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in :0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer:0
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (Xamarin.Forms.VisualElement view) [0x0003e] in :0
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in :0
at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child) [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:337
at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:750
at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:464
at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:427
at System.Collections.ObjectModel.ObservableCollectionb__0 () [0x00029] in /Users/jijithvasudevan/Downloads/XamForms.Controls.Calendar-master/XamForms.Controls.Calendar/Calendar.cs:513
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---
1[TElement].Dispose (System.Boolean disposing) [0x0007d] in <db147fad2aa9412c845ff0ead92dfe20>:0 at Xamarin.Forms.Platform.iOS.ViewRenderer
2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in1[TElement].Dispose (System.Boolean disposing) [0x00058] in <db147fad2aa9412c845ff0ead92dfe20>:0 at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/Foundation/NSObject2.cs:147 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in <db147fad2aa9412c845ff0ead92dfe20>:0 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in <db147fad2aa9412c845ff0ead92dfe20>:0 at Xamarin.Forms.Platform.iOS.VisualElementRenderer
1[TElement].Dispose (System.Boolean disposing) [0x00058] in1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 at System.Collections.ObjectModel.ObservableCollection
1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:182 at System.Collections.ObjectModel.Collection
1[T].RemoveAt (System.Int32 index) [0x0002b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:146 at Xamarin.Forms.TemplateUtilities.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00018] in D:\a\1\s\Xamarin.Forms.Core\TemplateUtilities.cs:63 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:445 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:379 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:316 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:293 at Xamarin.Forms.ContentView.set_Content (Xamarin.Forms.View value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\ContentView.cs:11 at XamForms.Controls.Calendar+<>c__DisplayClass89_0.at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:63 at CalendarDemo.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jijithvasudevan/Downloads/XamForms.Controls.Calendar-master/Example/CalendarDemo/CalendarDemo.iOS/Main.cs:17