Well, in the end, I've managed to get it working using the series DataContext.
I'm still operating very much in the C# paradigm, and still (even in VS2010) find working in XAML a frustrating experience. If you're not doing it every day, all day, it is quite hard to gain much fluency, and too easy to fall back on C# code behind in the name of getting it done. And it seems that once you've done it for one thing, you are pretty much stuck then, as all the neat XAML shortcuts I could have taken seem unavailable to me now that so much else is being done in code-behind. I'd like to see a guide to refactoring forms from C# to XAML, explaining, for instance, how to take data bound controls that are populated from C# and port it into XAML. Anyway... Dylan. ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Dylan Tusler Sent: Wednesday, 1 September 2010 1:49 PM To: 'ozDotNet' Subject: Charting with WPF and Linq __ <http://www.sunshinecoast.qld.gov.au/> I have a .NET 3.5 WPF app (working on it in VS2010). On one of the windows, is a grid that is populated with data from an in-memory LINQ to SQL object (the hard way, in code instead of in bindings.) I am trying to drop a simple line graph underneath it, and am struggling to find a good example. Most web sites I've found are either talking about creating a chart completely from scratch in XAML. I haven't seen any examples of creating a chart and populating it via C#. I'm using the WPF Chart control, which seems pretty good. My datasets are pretty small, so I was thinking I'd just create a PointCollection and populate it with Point objects that represent each data point, but since my graph is a series over time, I can't see how I get a value (Y) and date (X) value into a point in .NET 3.5. I would then assign the PointCollection to a Series that I've already created, and set the minimum and maximum values for the Axes accordingly. (My X axis is already set up with dates, and that seems to work. Just can't get the Point to accept a date.) I feel like I'm on the wrong track and there should be some better way. Can I just use the DataContext of the chart directly? Am I missing something basic? There doesn't seem to be any good examples of doing this anywhere that I can find. Cheers, Dylan Tusler ________________________________ To find out more about the Sunshine Coast Regional Council, visit your local office at Caloundra, Maroochydore, Nambour or Tewantin or visit us online at www.sunshinecoast.qld.gov.au<http://www.sunshinecoast.qld.gov.au/>. If correspondence includes personal information, please refer to Council's Privacy Policy<http://www.sunshinecoast.qld.gov.au/sitePage.cfm?code=disclaimer>. This email and any attachments are confidential and only for the use of the addressee. If you have received this email in error you are requested to notify the sender by return email or contact council on 1300 00 7272 and are prohibited from forwarding, printing, copying or using it in anyway, in whole or part. Please note that some council staff utilise Blackberry devices, which results in information being transmitted overseas prior to delivery of any communication to the device. In sending an email to Council you are agreeing that the content of your email may be transmitted overseas. Any views expressed in this email are the author's, except where the email makes it clear otherwise. The unauthorised publication of an email and any attachments generated for the official functions of council is strictly prohibited. Please note that council is subject to the Right to Information Act 2009 (Qld) and Information Privacy Act 2009 (Qld). ------------------------------------------------------------- To find out more about the Sunshine Coast Regional Council, visit your local office at Caloundra, Maroochydore, Nambour or Tewantin or visit us online at www.sunshinecoast.qld.gov.au. If correspondence includes personal information, please refer to Council's Privacy Policy at http://www.sunshinecoast.qld.gov.au . This email and any attachments are confidential and only for the use of the addressee. If you have received this email in error you are requested to notify the sender by return email or contact council on 1300 00 7272 and are prohibited from forwarding, printing, copying or using it in anyway, in whole or part. Please note that some council staff utilise Blackberry devices, which results in information being transmitted overseas prior to delivery of any communication to the device. In sending an email to Council you are agreeing that the content of your email may be transmitted overseas. Any views expressed in this email are the author's, except where the email makes it clear otherwise. The unauthorised publication of an email and any attachments generated for the official functions of council is strictly prohibited. Please note that council is subject to the Right to Information Act 2009 (Qld) and Information Privacy Act 2009 (Qld).
