We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfChart is crashing if ChartTitle is not hardcoded in xaml (UWP only)

I am binding sfChart dynamically in viewmodel and it works fine in Android but in UWP, it crashes with the exception below. It works only if I hardcode something like
  <chart:ChartTitle Text="title"/>


Binding from ViewModel:
  <chart:SfChart.Title>

                <chart:ChartTitle Text="{Binding ChartTitle}"/>

            </chart:SfChart.Title>


System.ArgumentNullException occurred
HResult=0x80004003
Message=Value cannot be null.
Source=
StackTrace:
at System.StubHelpers.HStringMarshaler.ConvertToNativeReference(String managed, HSTRING_HEADER* hstringHeader)
at Windows.UI.Xaml.Controls.TextBlock.put_Text(String value)
at Syncfusion.SfChart.XForms.UWP.ChartTitleMapping.OnChartTitlePropertiesChanged(String propertyName, ChartTitle formChartTitle, Border border)
at Syncfusion.SfChart.XForms.UWP.SfChartMapping.OnChartPropertiesChanged(String propertyName, SfChart formsChart, SfChart nativeChart)
at Syncfusion.SfChart.XForms.UWP.SfChartRenderer.GetNativeChart(SfChart sfChart)
at Syncfusion.SfChart.XForms.UWP.SfChartRenderer.OnElementChanged(ElementChangedEventArgs`1 e)
at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.OnChildAdded(Object sender, ElementEventArgs e)
at Xamarin.Forms.Platform.UWP.VisualElementPackager.Load()
at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.SetElement(VisualElement element)
at Xamarin.Forms.Platform.UWP.Platform.CreateRenderer(VisualElement element)
at Xamarin.Forms.Platform.UWP.VisualElementExtensions.GetOrCreateRenderer(VisualElement self)
at Xamarin.Forms.Platform.UWP.NavigationPageRenderer.SetPage(Page page, Boolean isAnimated, Boolean isPopping)
at Xamarin.Forms.Platform.UWP.NavigationPageRenderer.OnPushRequested(Object sender, NavigationRequestedEventArgs e)
at Xamarin.Forms.NavigationPage.d__90.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.Forms.NavigationPage.d__48.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

5 Replies

DS Durgadevi Selvaraj Syncfusion Team August 1, 2017 10:41 AM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
We have analyzed the reported problem and unable to reproduced it at our end. We have prepared a demo sample with the reference of provided information and it can be downloaded from below link,  
 
Sample: Chart_Sample
 
If you are still able to reproduce the problem, please revert us by  modifying the provided sample. It would be helpful for us to provide a solution sooner. 
 
Regards,  
Durgadevi S 




EM Emil August 3, 2017 04:11 PM UTC

ah ok, i was using onappearing instead constructor. it works fine using constructor now. thank you



DS Durgadevi Selvaraj Syncfusion Team August 4, 2017 06:39 AM UTC

Hi Emil, 
 
We glad to know that your problem has been resolved. 
Please let us know if you need any further assistance. 
Regards, 
Durgadevi S 



EM Emil February 8, 2018 04:52 PM UTC

Hi,

although above workaround works, why is required to have chart:ChartTitle  ? this requirement not exist in Android but in UWP. please try not to set chartTitle at all or set in OnAppearing, you will see this crash.

thanks,

Emil


DS Durgadevi Selvaraj Syncfusion Team February 9, 2018 02:42 PM UTC

 
Thanks for the update. 
 
The null value is not accepted for the Text property of ChartTitle in UWP, so the app crashed in UWP alone. However, we can resolve this problem by setting default value as string.Empty to the ChartHeader property in ViewModel to resolve this issue. Please refer the below codes, 
 
Code Snippet[C#] 
private string _chartHeader = string.Empty; 
public string ChartHeader 
{ 
            get 
            { 
                return _chartHeader; 
            } 
            set 
            { 
                _chartHeader = value; 
                NotifyPropertyChanged("ChartHeader"); 
 
            } 
  } 
 
 
Please find the reference output screenshot below, 
 
 
We have modified the above sample based on this and it can be downloaded from the below link, 
Sample:SfChart_Title
 
 
Please let us know if you have any concerns. 
 
Regards,  
Durgadevi S 


Loader.
Live Chat Icon For mobile
Up arrow icon