Silverlight WCF RIA Services/VS2010 Beta 2 Workaround
I was working my way through the Hands-on Lab: Silverlight 4 Line of Business Application using WCF RIA Services when I encountered a show-stopper issue.
To avoid it, change the default Tools/Options setting in VS2010 Beta 2 as shown below. This will work around a beta 2 IntelliTrace bug when building a Silverlight 4 solution with WCF RIA Services.
Thanks to Microsoft RIA Services team (esp. Deepesh Mohnani, Saurabh Pant, and Wilco Bauwer) for answering my Twitter plea for help, and staying with me until the workaround surfaced.
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!
Having Choices and Making Them
I’ve come to blogging reluctantly. With more than reluctance really; comfortable for decades consuming the published thoughts of others, this is for me a sea change. Yet not only was my choice to be a passive consumer rooted in comfort. I have been keenly aware I was not one of the giants of my industry, the giants who possessed not only the requisite intelligence, but also the good fortune, exquisite timing and existing network of influentials to facilitate inventing and bringing to market entirely new concepts, devices, and businesses. No Steve Jobs I. So without rancor, I have accepted my role as one of the teeming hordes of workers worldwide toiling in the vineyards laid out by the leaders of my industry.
In truth I’ve not been so passive all this time, I’ve had moments of “Carpe diem”. What Day Seizing chiefly taught me though is that while close counts in horseshoes, it does not count so much in new business startups. As example, and because it is a tale worth telling, more than a decade ago I had a “Great Idea”. I had credibility enough to sell the Great Idea to my local engineering group and obtained funding for a working prototype. In short order, the team built it, and the Great Idea exceeded all our expectations. I had the technical excellence to run the team that created the prototype, but all of this was not enough. Getting that Great Idea from prototype to production now, that was a corporate hurdle I did not know how to clear. Still, sensing this was a Great Idea, and a moment not to be lost, the local management team of the organization of which I was a part, MCI Mail Engineering, got on an airplane and pitched the Great Idea to our Reston, VA, Corporate Vice President in charge of MCI Mail. He responded, “Who needs browser access to their email?” It was not a question. We were instructed to curtail all further work and return to his priorities. I put away the domain registration form I had already filled out with “www.HoTMaiL.com”.
There is a Taoist story of an old farmer who had worked his crops for many years. One day his horse ran away. Upon hearing the news, his neighbors came to visit.
“Such bad luck,” they said sympathetically.
“We’ll see,” the farmer replied.
The next morning the horse returned, bringing with it three other wild horses.
“How wonderful,” the neighbors exclaimed.
“We’ll see,” replied the old man.The following day, his son tried to ride one of the untamed horses, was thrown, and broke his leg. The neighbors again came to offer their sympathy on his misfortune.
“We’ll see,” answered the farmer.
The day after, military officials came to the village to draft young men into the army. Seeing that the son’s leg was broken, they passed him by. The neighbors congratulated the farmer on how well things had turned out.
“We’ll see” said the farmer.
I took away several lessons from that experience, nearly all of them positive. The one that still resonates for me though is that even for a Great Idea, for a vision of such brilliance that only the blind could fail to see it, a case must be made. Even Great Ideas must be sold (and perhaps the more world-changing, the more needed) , alliances must be formed, and a plan of execution to bring the Great Idea to market spelled out. In my Dilbertesque engineering world, simply demonstrating a Great Idea with enthusiasm was sufficient to justify further investment. The Corporate VP was only following a time-honored script. We were too enamored of our engineering success, which left us unprepared to respond to a question we considered so naive as to be unworthy of discussion by intelligent life. So our window of opportunity slammed shut. We had also left ourselves without the right allies to face this key decision maker, allies who could anticipate and prepare for this question, and those additional questions that would have followed had we been able to field the first. The outcome encouraged me to leave the ranks of anonymous engineers and join the ranks of the aspiring middle-management.
What happened next?
We’ll see…