Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to implement link sharing using the Cimalino Windows Phone Toolkit

From Wiki
Jump to: navigation, search

This article shows how to launch a dialog that enables the user to share a link on the social networks of their choice using ShareLinkService from the Cimbalino Windows Phone Toolkit.

WP Metro Icon Messages.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code Example
Source file: ShareLinkService Example (Github)
Tested with
SDK: Windows Phone 8.0 SDK, Windows Phone 7.1.1 SDK
Devices(s): Nokia Lumia 800, 920
Created: saramgsilva (08 Nov 2013)
Last edited: hamishwillee (25 Nov 2013)



The Cimbalino Windows Phone Toolkit delivers a set of useful and powerful MVVM-compatible tools and services to help developers build Silverlight applications for Windows Phone. The Toolkit is divided in projects which deliver different features, ranging from base MVVM services and helpers, through to code for background agents, and for accessing media library, location services etc.

The Cimbalino Toolkit's "Share Link" service is an MVVM compatible wrapper around the system ShareLinkTask, which can be used to launch a dialog to share links via social networks configured on the device. The kit provides both the IShareLinkService interface and its implementation ShareLinkService required to register the service in MVVM Light (note that MVVM and the MVVM Light Toolkit are not "preconditions" to use this service).

This article explains how to use the service in an MVVM Light app. Developers should first read How to use MVVM Light Toolkit for Windows Phone for a general overview of MVVM Light and how to use services.

Screenshot of the example app - showing the sharing button.

Building the example code

The source code for the code example is available here: ShareLinkService Example (Github)

To build the source code you will also need the MVVM Light Toolkit and the Cimbalino Windows Phone Toolkit. Their packages are available in the Nuget Package Manager. For more details see:

The sample is built using MVVM Light and the article does not go into great detail about the plumbing/infrastructure provided by the toolkit. For more information see:

Registering the service

Register the service in the ViewModelLocator constructor as shown below.

 /// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (!SimpleIoc.Default.IsRegistered<IShareLinkService>())
SimpleIoc.Default.Register<IShareLinkService, ShareLinkService>();
public MainViewModel MainViewModel
return ServiceLocator.Current.GetInstance<MainViewModel>();
public static void Cleanup()
// TODO Clear the ViewModels

Implementing the ViewModel

Implement the MainViewModel as shown below. The highlighted sections show the MainViewModel constructor taking the IShareLinkService parameter and assigning it to the private variable. Later on the private member is used to show the link service.

public class MainViewModel : ViewModelBase
/// <summary>
/// The share link service.
/// </summary>
private readonly IShareLinkService _shareLinkService;
/// <summary>
/// The public application url.
/// </summary>
private readonly string _appUrl;
/// <summary>
/// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// </summary>
/// <param name="shareLinkService">
/// The share Link Service.
/// </param>
public MainViewModel(IShareLinkService shareLinkService)
_shareLinkService = shareLinkService;
ShareSocialNetworkCommand = new RelayCommand(ShareSocialNetwork);
_appUrl = string.Concat("");
/// <summary>
/// Gets the share social network command.
/// </summary>
public ICommand ShareSocialNetworkCommand { get; private set; }
/// <summary>
/// The share social network.
/// </summary>
private void ShareSocialNetwork()
const string Message = "This application is amazing, should try it! See in";
_shareLinkService.Show("Cimbalino Toolkit Sample", Message, new Uri(_appUrl, UriKind.Absolute));

Implementing the view

The rest of the app is "plumbing" to hook up the MainViewModel to the View and send commands back to the invoke the service. How to use MVVM Light Toolkit for Windows Phone explains most of what is going on.

Add the binding in main page as shown:

 DataContext="{Binding MainViewModel,
Source={StaticResource Locator}}"

The MainPage.xaml can be the following:

<phone:PhoneApplicationPage x:Class="CimbalinoSample.MainPage"
DataContext="{Binding MainViewModel,
Source={StaticResource Locator}}"

FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
<!-- LayoutRoot is the root grid where all page content is placed -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<!-- TitlePanel contains the name of the application and page title -->
<StackPanel x:Name="TitlePanel"
<TextBlock Margin="12,0"
Style="{StaticResource PhoneTextTitle2Style}"
Text="Cimbalino Toolkit Sample" />
<TextBlock Grid.RowSpan="2"
Style="{StaticResource PhoneTextTitle3Style}"
This samples has the goal to show how to use Cimbalino Toolkit - ShareLinkService.
<!-- ContentPanel - place additional content here -->
<Grid x:Name="ContentPanel"
Margin="12,0,12,0" />
<cimbalino:ApplicationBarIconButton Command="{Binding ShareSocialNetworkCommand,

Text="Share it" />

Related samples

Source Code

The source code is availabe here.

This page was last modified on 25 November 2013, at 03:00.
58 page views in the last 30 days.