Windows 8 RT & Caliburn.Micro – Being a share source

By Dries Marckmann
February 11, 2013
0

If you want to know how to share be a share target rather than the source, go here.

Being is the source of the share action is simple.

In the ViewModel where you have the content you want to share, add this:

protected
override
void OnActivate()

{


base.OnActivate();


DataTransferManager.GetForCurrentView().DataRequested += OnDataRequested;

}


protected
override
void OnDeactivate(bool close)

{


base.OnDeactivate(close);


DataTransferManager.GetForCurrentView().DataRequested -= OnDataRequested;

}


protected
void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)

{


var request = args.Request;


var requestData = request.Data;

requestData.Properties.Title = Title;

requestData.Properties.Description = Description;

requestData.SetUri(new
Uri(Url));

}

Basically, we subscribe to the DataRequested event and fill the Request that comes with the event arguments with the data we want to share.

Easy!

Comments: 0

Leave a Reply

Your email address will not be published. Required fields are marked *