You use this CLR object to create activities that will go into a user's activity stream


  • TemplateName the Template's name as entered in the MySpace Developer Platform
  • Priority the creation priority: opensocial.CreateActivityPriority.HIGH or opensocial.CreateActivityPriority.Low
  • MediaItems a List of the Media Item URLs


  • MakeRequest() Make the request to create the activity. You should save the state of the control to isolated storage beforem making this request because the opensocial.requestCreateActivity() method will trigger a popup window in MySpace which removes the Silverlight application from the DOM.

Using this class

  1. Derive a class from this MyOpenSpace.CreateActivityRequest</description>
  2. Add parameters specific to this activity request as class properties</description>
  3. Override OnGetTemplateParameters() to add the parameters to the dictionary

Example from Activities sample MyCreateActivitiesRequest.cs

namespace Activities
    using System.Collections.Generic;
    using MyOpenSpace;

    /// <summary>
    /// Activity request with an adjective parameter
    /// </summary>
    /// <remarks>this template has a ${adjective} parameter in its body</remarks>
    public class MyCreateActivityRequest : CreateActivityRequest
        /// <summary>
        /// Gets or sets the adjective
        /// </summary>
        public string Adjective { get; set; }

        /// <summary>
        /// Add the parameters for this activity request
        /// </summary>
        /// <param name="parameters">the parameters collection</param>
        public override void OnGetTemplateParameters(IDictionary<string, object> parameters)
            parameters.Add("adjective", this.Adjective);
The Silverlight Page which hosts the MyCreateActivityRequest as a resource:
<UserControl x:Class="Activities.Page"
    Width="400" Height="300">
        <local:MyCreateActivityRequest x:Key="CreateActivityRequest" Adjective="Cool" 
            TemplateName="Template_1" Priority="opensocial.CreateActivityPriority.HIGH">

    <Grid x:Name="LayoutRoot" Background="Azure">
        <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
            <TextBlock Text="Adjective: "/>
                Text="{Binding Adjective, Source={StaticResource CreateActivityRequest}, Mode=TwoWay}" 
            <Button Content="Create Activity" Click="OnCreateActivity"/>
The Silverlight page code behind
namespace Activities
    using System.Windows;
    using System.Windows.Browser;
    using System.Windows.Controls;

    /// <summary>
    /// Silverlight test page for CreateActivityRequest
    /// </summary>
    public partial class Page : UserControl
        /// <summary>
        /// Initializes a new instance of the Page class.
        /// </summary>
        public Page()

        /// <summary>
        /// Create a new activity
        /// </summary>
        /// <param name="sender">the button</param>
        /// <param name="e">the routed event arguments</param>
        private void OnCreateActivity(object sender, RoutedEventArgs e)
            var request = this.Resources["CreateActivityRequest"] as MyCreateActivityRequest;


Last edited Apr 29, 2009 at 9:51 PM by mscherotter, version 8


No comments yet.