Using the Kit in Visual Studio 2008

1. Create or open a new Silverlight 2 application
2. In the Silverlight application (the one with the Page.xaml file) add a reference to the bin\Release\MySpaceSilverlightKit.dll
3. Open the Page.xaml file in the Silverlight application project and add the namespace for MyOpenSpace to the <UserControl> element attributes: xmlns:MyOpenSpace="clr-namespace:MyOpenSpace;assembly=MySpaceSilverlightKit"
<UserControl x:Class="MyFriends.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"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    </Grid>
</UserControl>

4. Add one or more of the MyOpenSpace CLR objects to the UserControl.Resources section. Valid CLR objects are the MyOpenSpace.MySpacePersonRequest, MyOpenSpace.MySpacePeopleRequest, and MyOpenSpace.MySpaceVideosRequest.
<UserControl x:Class="MyFriends.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"
    Width="400" Height="300">
    <UserControl.Resources>
        <MyOpenSpace:MySpacePeopleRequest x:Key="MyFriends"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
    </Grid>
</UserControl>

5. Add attributes to the data sources when appropriate:
<UserControl x:Class="MyFriends.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"
    Width="400" Height="300">
    <UserControl.Resources>
        <MyOpenSpace:MySpacePeopleRequest x:Key="MyFriends" IdSpec="opensocial.IdSpec.PersonId.VIEWER" Max="1000"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
    </Grid>
</UserControl>

6. Add controls to bind to the data source.
<UserControl x:Class="MyFriends.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"
    Width="400" Height="300">
    <UserControl.Resources>
        <MyOpenSpace:MySpacePeopleRequest x:Key="MyFriends" IdSpec="opensocial.IdSpec.PersonId.VIEWER" Max="1000"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <ListBox HorizontalAlignment="Stretch" ItemsSource="{Binding People, Source={StaticResource MyFriends} }"/>
    </Grid>
</UserControl>

7. Compile and run the application on your test. When Testing on your local system (not on MySpace) you might get error messages on starting up the Silverlight application saying that opensocial is undefiend. This is because the kit is trying to communicate with MySpace’s OpenSocial-based developer platform –which is not on your development system. It is safe to check the Do not show this message again checkbox and press the No button.
8. You should then see the application running with using sample data.
9. Upload your application to your web server.

Last edited Mar 31, 2009 at 6:26 PM by mscherotter, version 8

Comments

No comments yet.