MyOpenSpace.HtmlToEnumerableConverter

Some of the object properties in MySpace return the text or HTML that the user inputted rather than a collection of strings. These include a person's Heroes, Books, Movies, Music, and Interests. If the text in these profile is valid XHTML using <li> elements or the text is separated by newline characters, then this value converter converts the single string to a collection of strings
This will work:
<ul>
    <li>Catcher in the Rye</li>
    <li>To Kill a Mockingbird</li>
    <li>The Fountainhead</li>
</ul>
This will work:
Catcher in the Rye
To Kill a Mockingbird
The Fountainhead

This will not work:
<li>Cather in the Rye
<li>To Kill a Mockingbird
<li>The Fountainhead

Example

<UserControl x:Class="Test_Silverlight_Kit_for_MySpace.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:MyOpenSpace="clr-namespace:MyOpenSpace;assembly=MySpaceSilverlightKit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <UserControl.Resources>
        <MyOpenSpace:MySpacePersonRequest x:Key="Owner" 
             IdSpec="opensocial.IdSpec.PersonId.OWNER" 
             RequestFields="opensocial.Person.Field.BOOKS"/>
        <MyOpenSpace:HtmlToEnumerableConverter x:Key="BooksConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <ListBox DataContext="{StaticResource Owner}"
            ItemsSource="{Binding People.Books, Converter={StaticResource BooksConverter} }"/>
    </Grid>
</UserControl>

Last edited Apr 6, 2009 at 8:39 PM by mscherotter, version 7

Comments

No comments yet.