Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get started? #1

Closed
mennodeij opened this issue Feb 29, 2016 · 2 comments
Closed

How to get started? #1

mennodeij opened this issue Feb 29, 2016 · 2 comments

Comments

@mennodeij
Copy link
Contributor

Hi,

I'm wondering how to use this with Eto-Wpf. I've tried a few things, but always get an ArgumentOutOfRangeException with the following message:
{"Specified argument was out of the range of valid values.\r\nParameter name: Type for 'Eto.OxyPlot.Plot' could not be found in this platform"} with stacktrace

at Eto.Widget..ctor()
at Eto.OxyPlot.Plot..ctor()
at EtoOxyPlotTest.MainForm..ctor() in D:\zandbak\EtoOxyPlotTest\EtoOxyPlotTest\MainForm.xeto.cs:line 25
at EtoOxyPlotTest.Desktop.Program.Main(String[] args) in D:\zandbak\EtoOxyPlotTest\EtoOxyPlotTest.Desktop\Program.cs:line 12

I use the following MainForm.xeto XAML file

<?xml version="1.0" encoding="UTF-8"?>
<Form
    xmlns="http://schema.picoe.ca/eto.forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="My Eto Form"
    ClientSize="400, 350"
    >
  <StackLayout ID="_my" />

</Form>

and code-behind

public MainForm()
{
    XamlReader.Load(this);
    StackLayout sl = FindChild<StackLayout>("_my");

    Plot p = new Plot(); // here I get the exception
    p.Model = new PlotModel();
    p.Model.Title = "Example";
    p.Model.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.01, "cos(x)"));
    sl.Items.Add(new StackLayoutItem(p));
}

I would be very grateful if you could share an example project or help me to get this working.

@mennodeij
Copy link
Contributor Author

FWIW i figured it out, had to put the platform handler in the Main() method.

var pf = Platform.Detect;
if (pf.IsWpf)
{
    pf.Add(typeof(Plot.IHandler), () => new Eto.OxyPlot.Wpf.PlotHandler());
}

else
{
    Console.WriteLine($"{pf.ID} is not supported.");
    return;
}

new Application(pf).Run(new MainForm());

@LorenVS
Copy link
Owner

LorenVS commented Mar 1, 2016

Ah yes, sorry for not getting back to you sooner. Glad you were able to figure this out on your own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants