On Text and Silverlight
I recently had occasion to implement another one of my Great Ideas <grin/>. Okay, not so Great. Thought I, would it not be interesting to showcase my resume content within a dynamic Silverlight application? Why of course it would, replied I.
I set about to find an interesting framework to house my history, and in short order settled on one I found visually appealing, the Silverlight User Group Website Starter Kit. I suppose what drew me were these few words….
…it can easily be adapted to suit other purposes
Well, “other” certainly described my purpose! The SLUG Website Starter kit is the child of David Silverlight, with some key components derived from David Kelley’s Crossfader project. I suspect I took this code in a direction beyond their imagining, and that once I release my creation on an unsuspecting planet, any moment after that the broad declaration of “other purpose” will disappear from Codeplex. Though in a very early alpha stage of development, the SLUG Website Starter Kit is under active development, and the recommended source I started with provided me with the framework for the kind of visual appeal I was looking for. In a short time I understood the wiring between components. And it was at that point the project got interesting.
It became clear the remaining tasks fell in the category of text formatting, that is, accomplishing in Silverlight XAML what I had already easily accomplished in WYSIWYG Word. I had no illusions a straight conversion from Word to XAML was feasible. However, Word to HTML came in the box. whatever one might think of WordHTML and that will display in a vanilla HTML page. So I thought, might it not be possible to substitute equivalent Silverlight XAML for HTML? Well, the answer turns out to be Yes. And No.
Parenthetically, I did take a long look at Michael Scherotter’s (Synergist) Word 2007 to XAML generator, which does not seem to be getting any attention at this time.. While nicely integrated into Word 2007 and a single click to use, it’s Silverlight output is constrained by Silverlight text formatting capabilities and I abandoned the approach with regret.
Markus Egger recently published a post-mortem on a software project for a startup company that concerns itself with high-tech digital software escrow.
There is no way to sugarcoat this: Silverlight is very poor for text formatting
Now this seems odd. Let’s face it. The internet runs on text. This, what you’re reading, this is text. Search runs on text. Yes, even in this day of streaming video, in the age of YouTube, the only way to use a search engine to find that video content is by searching not for the video content itself, which is beyond what we can do today, but for a tag on the video, which is of course text, and no part of the video itself. So why, with Silverlight 4 just around the corner, is support for text still incomplete?
What’s that you say? Incomplete? Why Silverlight has TextBlocks. And TextBocks have FontFamily, FontSize, FontWeight, and Font Etc. properties! Not to mention Foreground, Horizontal Alignment, LineHeight, Margin, Max & Min Height & Width, Opacity & with a Mask, Padding, Projection, RenderTransform & Etc, Text Alignment, Decorations, Trimming, & Wrapping. What more could you possibly want?
To begin to answer this question, let’s look at the tool bar of a good-enough HTML text editor, which provides only the most essential HTML. To compose these posts, I use Windows Live Writer, a minimalist HTML text editor which provides me with both a WYSIWYG and a raw HTML view into the text I am preparing to blog. And as you might expect, it sports a simple minimalist toolbar.
Ignoring the buttons which are clearly artifacts of editor functionality, all the other buttons insert HTML into the document. But what if instead of using an editor which emits HTML I wanted it to emit XAML? What would that toolbar look like today?
Markus has this to say,
Blocks of text support very simple formatting such as bold and italic, but even seemingly simple concepts such as paragraphs are not supported. Text can be left or right aligned or centered. Justified text is not available. Alignments are set for entire blocks and not for individual lines or paragraphs. This means it is not natively possible to create a block with a centered heading and the remainder being left aligned or justified.
As you can imagine, all this is a bit of a problem for a system that deals (at least occasionally) with large amounts of legal text. It always seems to me that the Web’s origins are very much in the realms of document definition (after all, that is what HTML was originally created for) and it seems odd that a Web-only technology like Silverlight has practically no features for document or text formatting.
At some point, we even experimented with our own layout and text rendering engine that supports some of the features provided by Flow Documents or XPS in WPF. We also experimented with a PDF viewer written entirely in Silverlight. However, we decided that even a relatively simple initial engine would be too time consuming to build. We may still roll this engine out at some point (probably as part of Milos), but we put this effort on hold in favor of pushing the initial Tower48 version out as quickly as possible.
For the time being, however, we had no choice but to live with the capabilities provided by Silverlight and to limit ourselves to very simple text formatting options such as bold and italic with various fonts and sizes mixed in.
Here at the end, I should point out that there have been several attempts made in the community to plug the gaps in Silverlight text formatting I encountered, and I have availed myself of both of them.
Jeremy Likness recently blogged here the steps to create a workaround class to compensate for Silverlight XAML’s inability to embed hrefs in a line of text. I reused his code.
Matt Perdeck wrote a very useful class to emulate HTML’s "”ol, ul, li” markup, which I reused. Note if you do so also that it does not build with Silverlight 3 and that suggestions by “DT” on that page must be followed.
Note also that Devexpress sells what looks like a very nice Silverlight Rich Text editor (AgRIchEdit)control as a part of their DXperience™ Silverlight Subscription.
Get a load of that toolbar!
My budget simply would not permit, or I might be reviewing it for you now.
Finally, I’d like to believe I am now aware of the state of text processing capabilities in Silverlight 3 and 4. However, I know that somewhere out there is something I missed, and I know all too well in the six months I have been immersed in Silverlight the state of the art is always moving. I welcome any comments which update or correct any statement I’ve made in this post.
Oh, and finally, thank you John! I could not resist!
Buy:Lumigan.Actos.Valtrex.Petcam (Metacam) Oral Suspension.Accutane.Zovirax.Arimidex.Nexium.Prednisolone.Human Growth Hormone.Zyban.100% Pure Okinawan Coral Calcium.Prevacid.Mega Hoodia.Retin-A.Synthroid….
teal http://stealy0iaw40.02JEEPPARTS.US/tag/t70+teal+still/ : still…
t70…