The Silverlight DataPager never gives me a page count greater than 1. - silverlight

I've decided that RIA Services is way too limiting and am attempting to role my own server side pagination. I've long since switched over to plain old WCF. Everything is going wonderfully. My only problem, ironically, is with the front end. I'm trying to get the DataPager control to work. I could have (and it seems should have) created my own DataPager control, but I didn't want to take the time to write something as nice as the DataPager is (the control itself, not the client side query nonsense). The trouble I face, probably obviously, is setting the page count within the pager. It seems that the data pager is automagically tied to RIA services. I've tried creating an implementation of IEnumerable and IEnumerable<T> that only references a count (i.e. returns n of default(T)). I've tried using arrays of integers. All of these techniques are very wasteful and whats more, they don't work. I am to the point where it would have been much faster to write my own data pager than to use this one. So I thought I'd ask what I'm doing wrong (i.e. though I know that ultimately my wrong is in using this control without the beloved RIA client side query at all).

I figured it out. I wasn't using the PagedCollectionView.

Related

Intercepting and Injecting in the Windows Message Loop

We are using a poorly designed Windows engineering application in our office that does not allow importing of model definition data (as most other applications do). We can spend literally 1.5 weeks pointing and clicking in the GUI adding nodes, elements, etc. I will call this poorly written application "X".
So, would it be possible to write a parent application (I code C, C# & know how to read Petzold/Win32 a bit) that essentially would fire up this application "X" and intercept and inject windows messages into it's loop, so say, I could automatically fill in winform fields, and at least see what messages are being passed around? That way I could possibly script part of the repetitive elements of the GUI.
Thanks for any potential leads and starting points.
-jdrago

Building a SIlverlight Entity Framework application with no data initially

I have found many samples and examples of silverlight applications that use EF for their data store. Why is it that every single one uses a database full of data and shows how to edit/save? I'm having problems setting up an application where I (want to) have no data to start with and would like my user to then populate the data store. Everything works fine when data exists but I get into all sorts of null problems when I want to start with no data.
Just saying...
ANyway, my question: Does anyone know of any tutorials that demonstrate code where no data yet exists?
Thanks!
(Sorry for my bad english)
I suppose you are using RIA Services? That's the easiest way to develop an SL app with EF. It should make no diference between having data or not, the RIA Service returns a collection with 0 or more itens, you bind that with a DataGrid and are done. Here is a link with source code of a full aplication, that starts with no data: http://johnpapa.net/wcf-ria-services-hands-on-lab - What is most important to understand is the asynchronous nature of RIA Services. Keep that in mind, take a look and try the code.
If you have more questions, try to be more specific about the exact errors or problems you are facing, it would be easy to others try to help you :)

Need some WinForms and DataSet advice

Here's the story: I've been working on putting together an app in VS10 using Windows Forms in C++. This is my first experience with winforms, although I have a fair amount of experience with C++ and have worked with MFC a bit. The program needs to aquire data input from a hardware measurement system and the backend for that is mostly worked out. What I've been a bit stuck on is how to easily work with displaying this data in forms with the DataGridView and Chart objects. I'd also like to be able to save various sets of data and the programs current settings to disk that can be easily recalled and displayed in the program at a later point.
The solution I've been attempting so far has been to create a DataSet object for a certain program instance which holds some DataTables for the data and current settings. This is easily saved and read to XML files using the DataSet methods, which is nice. The tricky part for me using this method has been trying to sync up the program's display data and settings in the DataGridViews and Charts. It seems like these controls are really meant to be designed through the GUI. Maybe I'm just a noob, but I couldn't figure out how to get the DataSet I designed to link with my Charts using the "Add Project data source" dialog, so instead I set up a bindingSource and then proceeded to set Chart settings manually in the code. That's been getting hairy pretty quickly.
What would you have done to implement this, and how would you advise proceeding? I'm sure there has to be a much simpler way of doing this.
I've used Microsoft Chart Controls to display data from hardware measurement systems before with good results.
We store our data separately in arrays and when we want to display something, just call the AddXY function on the items to add a point. Configuring the graph in the first place is more easily done in designer though. Have a look at the samples for more info.

Creating Reports in Silverlight (either as PDF or send it off to a printer)

I have recently attempted to generate reports in Silverlight 4. In my problem domain, these reports either need to go directly to the printer and/or the client-side SL application creates a PDF and allows the user to store it somewhere.
As for the report, it's roughly composed of 50% flow text (incl. enumerations), 30% tables and 20% charts. The flow text part makes it slighty more challenging, as proper line breaking would have to take place.
So far, I have tried the following approaches - each with its own shortcomings that make them not so much feasible:
Silverlight's own PrintDocument: technically, there are two major concerns. For one, getting page breaks to work and printing UIElements on it with proper layout is a bit of a dirty hackjob and full of compromises; thankfully that's the part I've managed to get working so far. However, the PrintDocument class always renders all visuals as bitmaps before sending them off; this is not so much fun, if one uses a PDF printer and hopes to still be able to search in / select text. David Poll's approach in "Silverlight and Beyond" [1] wasn't that helpful as well as it inherently follows the same approach and thus suffers from very similar issues.
silverPDF [2]: a barely documented library that requires to do most of the layout manually (the former approach at least allowed me to re-use Silverlight's layouting engine). So far, I see no way to (for instance) measure paragraphs and the only sample with long flowtext uses hardcoded absolute values for layout rectangles. Also, the developing party seems to be inactive.
Personally, I'm now thinking of following an entirely different strategy: simply generate HTML documents. But I was hoping that the community here might have hints for the two approaches above or know other good approaches.
Thanks in advance,
~Manny
Do you need to generate the report on the client, or can you get the server to generate it? Your options are better if you can generate it on the server. Personally, I think the way Silverlight printing works at the moment is pretty poor for report usage (sending each page to the printer as raster rather than vector, resulting in potentially huge amounts of data travelling through the network, and lower printing quality output). I've found the best strategy is to generate the PDF on the server (enabling you to take advantage of a reporting engine), and display it in your application. There are also a few commercial products (such as Telerik's Silverlight Report Viewer, Report Sharp Shooter, or even First Floor Software's Document Toolkit). If a client side solution is really required, perhaps one of these might be the best option (although the printing quality will still be poor). Note that Silverlight 5 is supposed to have support for vector printing, but it's another 6 months or more away from release. Yet another option is Pete Brown and David Poll's open source reporting framework here: http://silverlightreporting.codeplex.com/.
If you want to take the option of generating the report on the server as a PDF and displaying it in your application, I've written an article on doing so here: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. This doesn't work for OOB applications, but the source code accompanying my book (Pro Business Applications with Silverlight 4) does: apress.com/book/view/9781430272076.
Hope this helps...
Chris Anderson

Silverlight printing

What are my options for printing in Silverlight 3? Assume I have this awesome Silverlight application/control that creates a graphical display of some data. Now the user wants to print it.
I have considered a few options but I have yet to test any of these. Before I do that I would like to get some feedback on how it can be done.
Use the browser printing capabilites. In my experience this is does not provide a useful print, but perhaps with some interaction between the Silverlight host and the browser it can be done?
Use WriteableBitmap. The image can either be written locally, but this requires interaction from the user, or sent to the server where a suitable file (e.g. PDF file) can be generated and then sent back to the browser. Unfortunately you now get the overhead of sending the image twice across the network and increased complexity on the server side.
Send XAML back to the server that is then rendered in a WPF application running on the server. The result is the sent back to the client. I'm not sure if this is possible at all however, but if it is the network overhead is less than in option 2. Unfortunately, the complexity on the server side is even higher.
Wait for Silverlight 4?
One thing I have considered is that my awesome control probably will have a ScrollViewer at the highest level, but the user will want to print the entire content of the control, not just whatever is visible inside the bounds of the ScrollViewer. How can I handle this added complexity?
In all seriousness, I think your best option is to wait until Silverlight 4 if your client can wait that long. I've seen a good bit of buzz about SL 4 supporting printing on twitter, though it's not official. I'd wait until PDC in a few weeks and see if any Silverlight bits trickle out to support printing.
Take a look at SmartPrint for Silverlight 3: http://www.smartwebcontrols.com/SmartPrintDetails.aspx
TBH I wouldn't use any of those options:-
Printing from the browser. Fine if you are printing say a chart or something else that scales well on a single sheet of paper. Rubbish for anything else especially where you have scrolled content.
WriteableBitmap. I can't see a client-side only solution being acceptable to the user "Please save this and then print it" message. It could be made to work bouncing off the server but would be bad for bandwidth use (bandwidth is import right? because in a well-connect intranet you wouldn't using Silverlight?).
Sending XAML to server for rendering. Really awkward it would be WPF XAML not SL XAML, where and how would you do the binding, why send XAML at all, since the server needs to be pretty much clued in on this so why can't it hold the XAML needed as well. Or were you thinking of sending just pure XAML with all the data needed? Still its a lot of plumbing needed in the SL that isn't actually related to SL.
Use Silverlight 4, its possible that in the not to distant future this would be the correct no-brainer choice (personally I wouldn't hold my breath) but right now SL4 doesn't exist.
A 5th option
Place report generating code on the server and have the Silverlight app inform the server of the data set required (not necessarily posting the data merely the criteria needed to access the correct set). In my experience direct prints of GUIs aren't particularly satisfactory when the user really needs a good printed form of the data.
Its true that at times the user just wants to quickly get some offline access to a grid of data as it looks there and then. In that situation users often find an export to spreadsheet compatible file preferable to printing, which would be possible from SL.
Something akin to number two is pretty much your best bet and is what I've seen done for printing in most Silverlight apps so far.
You can have the app send content for printing back to the web server (i.e. a new handler or query string parameters to a printing page) and pop up another page for the user to print web content from, or you could allow the user to download a file and have them print that.
Sliverlight 3 does not support printing.
If you can wait for silverlight 4, they have given it "high priority"
If not use Writeablebitmap: http://www.andybeaulieu.com/Home/tabid/67/EntryID/161/Default.aspx

Resources