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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

An item with the same key has already been added.

Thread ID:





121065 Nov 7,2015 11:50 PM UTC Nov 9,2015 06:26 AM UTC Xamarin.Forms 2
Tags: SfChart
Ian Leatherbury
Asked On November 7, 2015 11:50 PM UTC

Trying to add 2 different Series to my line chart and getting the error: A System.ArgumentException was thrown: An item with the same key has already been added.

Here's my XAML:

<?xml version="1.0" encoding="UTF-8"?>
    xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms" >
        <chart:SfChart x:Name="CompareChart">

<!--        Primary Axis-->
              <chart:CategoryAxis LabelRotationAngle = "-45">
                  <chart:ChartAxisTitle Text ="Date"/>

<!--        Secondary Axis-->
                  <chart:ChartAxisTitle Text ="Price"/>
<!--            Line Graph-->
        <chart:LineSeries StrokeWidth="3" ItemsSource="{Binding StockData1}" XBindingPath="Date" YBindingPath="Close" x:Name="Series1">
                <chart:DataMarkerLabelStyle Angle ="315"/>

        <chart:LineSeries StrokeWidth="3" ItemsSource="{Binding StockData2}" XBindingPath="Date" YBindingPath="Close" x:Name="Series2">
                <chart:DataMarkerLabelStyle Angle ="315"/>

<!--      End Line Graph-->

Ian Leatherbury
Replied On November 8, 2015 06:02 AM UTC

Figured it out. They key was to enclose both Series within <chart:SfChart.Series>. e.g.

        <chart:LineSeries StrokeWidth="3" ItemsSource="{Binding StockData1}" XBindingPath="Date" YBindingPath="Close" x:Name="Series1">
        <chart:LineSeries StrokeWidth="3" ItemsSource="{Binding StockData2}" XBindingPath="Date" YBindingPath="Close" x:Name="Series1">  

Suresh B [Syncfusion]
Replied On November 9, 2015 06:26 AM UTC

Hi lan,

Thanks for using Syncfusion product.

We are glad to know that your issue is resolved. Please get back to us if you need any further assistance.

Thanks for your update.

Suresh B


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon