I have a custom Item template within a listview which actually includes a graph (pie chart). The xaml is as follows
<ListView x:Name="List1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" >
<chart:SfChart>
<chart:SfChart.BackgroundColor>
<Color>Gray</Color>
</chart:SfChart.BackgroundColor>
<chart:DoughnutSeries ItemsSource ="{Binding MyProperty}" XBindingPath="Item" YBindingPath="Value">
<chart:DoughnutSeries.ColorModel>
<chart:ChartColorModel Palette="Custom" CustomBrushes="{StaticResource Colors}"/>
</chart:DoughnutSeries.ColorModel>
</chart:DoughnutSeries>
</chart:SfChart>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Horizontal" >
<!--<Label Text="StartTime"></Label>-->
<Label FontSize="Small" Text="{Binding StartTime}"></Label>
<!--<Label Text="COunt"></Label>-->
<Label FontSize="Small" Text="{Binding QuestionCount}"></Label>
</StackLayout>
<StackLayout Orientation="Horizontal" >
<Label Text="Correct"></Label>
<Label FontSize="Small" Text="{Binding Correct}"></Label>
<Label FontSize="Small" Text="Incorrect"></Label>
<Label FontSize="Small" Text="{Binding Incorrect}"></Label>
<Label FontSize="Small" Text="Skipped"></Label>
<Label FontSize="Small" Text="{Binding Skipped}"></Label>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
When the pae is loaded the following code is run
QuizResults = GetTestHistory();
if (QuizResults.Count() != 0)
{
Data1 = new ObservableCollection<VmQuizData>();
//Lets use this to display the list
foreach (var item in QuizResults)
{
Data1.Add(new VmQuizData()
{
ID = item.Id,
Correct = item.Correct,
Incorrect = item.Incorrect,
Skipped = item.Skipped
});
}
List1.ItemsSource = Data1;
//List1.ItemsSource = QuizResults;
LblNoHistory.IsVisible = false;
List1.IsVisible = true;
}
else
{
LblNoHistory.IsVisible = true;
List1.IsVisible = false;
}
This displays the pie charts correctly and they are displayed for each item.
However, there is a refresh button which when clicked and should redisplay the data results in the correct values in the labels being displayed however the graphs are just shown as blank dark squares where the pie charts were previously displayed.
I'm not sure why the charts are not subsequently displaying despite the data showing correctly - or the way to remedy.
Attachment:
ChartProb_9b259b86.zip