Open
Description
Steps to reproduce
- Add a ListView to your ContentPage.
- Create a list of PlotModels to your page for binding to the ListView.
- Now use a Template/ ViewCell having PlotView to the ListView.
Platform: Xamarin Forms (Cross-Platform)
.NET version: 4.0
Expected behaviour
While loading the ContentPage, the ListView should load the data based on the PlotModels provided.
Actual behaviour
Everything is running smooth in Android. But the problem is I am getting a error "PlotModel is already in use by some other PlotView control" when I am trying to run it on IPhone.
//My content page
public MyConstructor()
{
List<MyChart> charts = new List<MyChart>();
charts.Add(new MyChart { PlotModel = PlotModel1 });
charts.Add(new MyChart { PlotModel = PlotModel2 });
charts.Add(new MyChart { PlotModel = PlotModel3 });
charts.Add(new MyChart { PlotModel = PlotModel4 });
ListView lvPlots = new ListView(ListViewCachingStrategy.RetainElement)
{
ItemsSource = charts,
ItemTemplate = new DataTemplate(typeof(NewDashboardSubCell)),
HasUnevenRows = true
};
Content = lvPlots;
}
public class MyChart
{
public MyPlotModel PlotModel { get; set; }
}
//My View Cell
public class NewDashboardSubCell : ViewCell
{
PlotView plotView;
public NewDashboardSubCell()
{
try
{
plotView = new PlotView
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
IsVisible = true,
IsEnabled = true,
HeightRequest = App.ScreenHeight - 100,
WidthRequest = App.ScreenWidth - 40
};
plotView.SetBinding(PlotView.ModelProperty, "PlotModel");
View = plotView;
}
catch (Exception ex)
{
}
}
}