1

I am using DataTransferManager to implement sharing within my WindowsPhone 8.1 app, it works fine although I have a small annoyance that I haven't been able to sort out.

I am populating request.Data.Properties.Title but when I share to Messaging, where there is nowhere to put a title, it puts it in the body of the message. Is there a way around this?

I have tried not supplying the Title property, or supplying an empty string, but that stops the share menu displaying at all.

EDIT: here is the code I am using:

private void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequest request = e.Request;
    request.Data.Properties.Title = "Generated Draw";

    request.Data.SetText(CreateDraw.formatDrawForSharing(currentDraw));
}
blawford
  • 435
  • 5
  • 18

3 Answers3

0

You mean the normal text message right? I don't think you can have a title for that.

SmsComposeTask smsComposeTask = new SmsComposeTask();

smsComposeTask.To = "thenumber";
smsComposeTask.Body = "Sometext here";
smsComposeTask.Show();

Did you try using these specific tasks or launchers?

Sharing from Windows Phone 8

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82
  • Yeah I do, although I don't want to be limited to just SMS. I have added the code I wrote in the original post. – blawford Jun 15 '14 at 15:45
0

The request.Data.Properties.Title property display or not display, it depends on the share target. For example, if you share with Messaging, it will display Title + Content together. But if you share with E-Mail, the Title will be displayed in the Mail Subject.

Chris Shao
  • 8,231
  • 3
  • 39
  • 37
  • I have added the code to the original post, with that code, if I select Messaging I get "Generated Draw" immediately followed by the string returned by `CreateDraw.formatDrawForSharing(currentDraw)`, all in the body of the message . – blawford Jun 15 '14 at 15:47
  • Oh, I see. In DataTransferManager, the Title and Text must not be empty. Maybe you can set the title to a WhiteSpace. – Chris Shao Jun 16 '14 at 01:04
0

I agree with Chris. I Don't think you can have a title for a message. Instead of the Data Transfer Manager you can try the ChatMessage though.

 using Windows.ApplicationModel.Chat;

var chatMessage = new ChatMessage();
chatMessage.Body = "Sometext here";
await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
AKM
  • 509
  • 9
  • 10