locked
How to display different text formats while sharing to different apps RRS feed

  • Question

  • I developed one windows store app and implemented share feature in that. everything is working fine. 

    now my requirements got changed and i need to implement share feature like if user selects "Mail" as target app it should send text and if user selects "People" as a target app then i need to set the uri 

    anyone can you please provide some sample regarding this.

    thanks.


    suresh

    Wednesday, February 12, 2014 9:19 AM

Answers

  • You can cache the request, and modify it after the target was chosen:

            DataRequest request;
    
            private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
            {
                request = args.Request;
    
                request.Data.Properties.Description = "...";
                request.Data.SetText("...");
            }
    
            private void DataTransferManager_TargetApplicationChosen(DataTransferManager sender, TargetApplicationChosenEventArgs args)
            {
                if (args.ApplicationName == "Mail")
                {
                request.Data.Properties.Description = "mail specific ...";
                request.Data.SetText("mail specific ...");
                }
            }

    • Marked as answer by Dev_SSC Wednesday, February 12, 2014 1:00 PM
    Wednesday, February 12, 2014 11:35 AM

All replies

  • Your app can find out which share target was chosen by the user, by registering an event handler on the TargetApplicationChosen event of the DataTransferManager. Its event argument (TargetApplicationChosenEventArgs) contains the name of the chosen target in the ApplicationName property.
    Wednesday, February 12, 2014 9:51 AM
  • That's right, but after this event raises we can say to which app we are sharing the content. Now how can i change the format of the text that i am going to share.

    Generally when user selects share from the charm bar or if we call the shareui programatically "DataRequestsed" event will be raised and all the data will be submitted by this event(formats everything). After that user may select any of the target apps now i need to change the format, this is my requirement please help me.


    suresh


    • Edited by Dev_SSC Wednesday, February 12, 2014 11:07 AM
    Wednesday, February 12, 2014 11:04 AM
  • You can cache the request, and modify it after the target was chosen:

            DataRequest request;
    
            private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
            {
                request = args.Request;
    
                request.Data.Properties.Description = "...";
                request.Data.SetText("...");
            }
    
            private void DataTransferManager_TargetApplicationChosen(DataTransferManager sender, TargetApplicationChosenEventArgs args)
            {
                if (args.ApplicationName == "Mail")
                {
                request.Data.Properties.Description = "mail specific ...";
                request.Data.SetText("mail specific ...");
                }
            }

    • Marked as answer by Dev_SSC Wednesday, February 12, 2014 1:00 PM
    Wednesday, February 12, 2014 11:35 AM
  • thanks Diederik Krols

    suresh

    Wednesday, February 12, 2014 1:00 PM
  • is this possible to windows phone? can I customize the text while sharing to social apps in windows phone.

    suresh

    Tuesday, March 11, 2014 2:03 PM
  • For help with Windows Phone app development please ask in the Windows Phone developer forums.

    Also note that for the specific scenario mentioned you shouldn't change behavior based on the target. You should provide both text and URL data types and let the target choose. You need to be very careful when targeting specific apps to make sure you don't break if the user chooses something else. Do not lock the user into choosing only specific targets.

    --Rob

    Tuesday, March 11, 2014 3:24 PM
    Moderator
  • thanks for your help, and sorry to post here about windows phone.


    suresh

    Wednesday, March 12, 2014 5:52 AM