Search code examples
c#uwptemplate10

How to override OnShareTargetActivated in Template10


I have a project that needs to receive data from Share-UI Windows 10. I have read documentation from Microsoft (https://learn.microsoft.com/en-us/windows/uwp/app-to-app/receive-data) and from that doc it says needs to override OnShareTargetActivated. my question is how to override OnShareTargetActivated in Template10?. so far what I can learn are only this.

enter image description here


Solution

  • We do not need to override OnShareTargetActivated in Template10. In the Template10.Common.BootStrapper class, we can see the OnShareTargetActivated that is a sealed method. We can not override the OnShareTargetActivated.

    In Template 10, the OnStartAsync is the one and only entry point to an application. In the OnStartAsync method, we can use the IActivatedEventArgs.Kind to get the ActivationKind. If it is activation by ShareSource, it will return ShareTarget. Then we can convert IActivatedEventArgs to ShareTargetActivatedEventArgs.

    There is a sample for ShareTarget in Template10, please refer it.