0

I created a xamarin forms project which is using oxyplot and Rg.Plugins.Popup xamarin forms. However, the graph does not work as excepted. I modified code refer to the link, but graph not show on UWP .

In addition, I init Rg.Plugins.Popup and oxyplot with follow code, I don't know what I doing wrong. Please help. thanks in advance.

in UWP project App.xaml.cs

Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies());

List<Assembly> assembliesToInclude = new List<Assembly>();

 //Now, add in all the assemblies your app uses
                assembliesToInclude.Add(typeof(OxyPlot.PlotModel).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(OxyPlot.PlotController).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(OxyPlot.Windows.PlotView).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.PlotView).GetTypeInfo().Assembly);
                assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer).GetTypeInfo().Assembly);

 try
 {
 Xamarin.Forms.Forms.Init(e, assembliesToInclude);
 // replaces Xamarin.Forms.Forms.Init(e);
 }
catch (Exception ex) { }

OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer.Init();

Xamarin forms and oxyplot version is

OxyPlot.Xamarin.Forms : 1.1.0-unstable0011

Xamarin.Forms: 4.2.0.709249

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
zhi qin wang
  • 105
  • 8
  • I tested with OxyPlot.Xamarin.Forms 1.1.0, it works in release mode for uwp platform. I could not reproduce your issue. – Nico Zhu Aug 26 '19 at 07:55
  • Thank you for your reply Nico Zhu. You are right. Oxyplot Xamrin 1.1.0 works in uwp release mode. The reason why oxyplot graph not display in my code is that I am using Rg.Plugins.Popup and Oxyplot. Xamarin.Forms.Forms.Init is different between that two NuGet Package. – zhi qin wang Aug 27 '19 at 05:20
  • For Rg.Plugins.Popup, I am using this code "Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies());". For Oxyplot, I am using "Xamarin.Forms.Forms.Init(e, assembliesToInclude);". If I comment out Rg.Plugins.Popup, Oxyplot works well in uwp release mode. However, when I use both of them, oxyplot not work. Do you have good idea? Thank you – zhi qin wang Aug 27 '19 at 05:22
  • I solved this problem. I modified List assembliesToInclude = new List(); to List assembliesToInclude = Rg.Plugins.Popup.Popup.GetExtraAssemblies().ToList(); . And I deleted Xamarin.Forms.Forms.Init(e, Rg.Plugins.Popup.Popup.GetExtraAssemblies()); – zhi qin wang Aug 27 '19 at 05:58
  • Yep, make sense, you could insert Popup assemblies into `assembliesToInclude` then use them in `Xamarin.Forms.Forms.Init` method. I have reply the answer please check. – Nico Zhu Aug 27 '19 at 06:14

1 Answers1

1

If you want to use both of them, you could insert their assemblie in the same list. For more please refer the following.

List<Assembly> assembliesToInclude = new List<Assembly>();

Popup.Init();
OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer.Init();

assembliesToInclude.Add(typeof(OxyPlot.PlotModel).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.PlotController).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.Windows.PlotView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.PlotView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer).GetTypeInfo().Assembly);
var assemblies = Popup.GetExtraAssemblies();

assembliesToInclude.AddRange(assemblies);
var count = assembliesToInclude.Count;

try
{
    Xamarin.Forms.Forms.Init(e, assembliesToInclude);

}
catch (Exception ex) {

}
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36