Welcome to MSDN Blogs Sign in | Join | Help

Code to support new features doesn't write itself [HtmlTextBlock sample gets data binding support!]

In the comments to my post about porting the HtmlTextBlock sample to Silverlight 2 Beta 1, kind reader eibrahim pointed out that Silverlight 2's data binding feature wasn't working with HtmlTextBlock. I explained why in a reply to that comment:

This is a consequence of me doing as simple a port as possible. :( Recall that Silverlight 1.1 Alpha did not support data binding, so this issue simply couldn't exist there. Now that Silverlight 2 Beta 1 supports data binding, HtmlTextBlock needs a minor change to support it. In particular, its properties need to be backed by DependencyProperties in order for data binding to work as we'd like. I'll be updating the sample soon to add this support ...

I've just finished updating the code to back each of the settable HtmlTextBlock properties that mirror TextBlock properties with a DependencyProperty in order to enable data binding and maintain HtmlTextBlock as "plug-compatible" with TextBlock as possible. Most of this was pretty straightforward (boring) typing, so I'll confess that I have not tested each property individually. :| But I did create a simple project (attached to this post) demonstrating HtmlTextBlock data binding - both standalone and within a ListBox DataTemplate - that interested readers can use to play around with this. I've also updated the HtmlTextBlock.cs file in the existing HtmlTextBlock source code download.

Thanks for the feedback, eibrahim, I hope you and others find that the new data binding support works well and enables even more compelling scenarios!

Published Tuesday, March 18, 2008 1:31 PM by Delay
Filed under:

Attachment(s): HtmlTextBlockAndDataBinding.zip

Comments

# madhavrao…

Thursday, April 03, 2008 1:47 PM by madhavrao…

# Again with the support for simple HTML display in Silverlight [HtmlTextBlock sample updated for Silverlight 2 Beta 2!]

Wednesday, June 11, 2008 1:15 PM by Delay's Blog

A customer recently asked about an update to my HtmlTextBlock sample for the newly released Silverlight

# My take on simple HTML display in Silverlight [HtmlTextBlock sample updated for Silverlight 2 RTW!]

Wednesday, November 12, 2008 1:15 AM by Delay's Blog

A couple of readers have asked about an update to my long-running HtmlTextBlock sample for Silverlight

# A fix for simple HTML display in Silverlight [HtmlTextBlock bug fix for Silverlight 2 RTW!]

Wednesday, November 12, 2008 3:17 PM by Delay's Blog

I updated my HtmlTextBlock sample for RTW last night and got an email from kind reader Ed Silverton this

Anonymous comments are disabled
 
Page view tracker