Hello,
Welcome to Microsoft Q&A!
Based on the Remarks part of FileSavePicker, it mentions
If you try to show the file picker while your app is snapped the file picker will not be shown and an exception will be thrown.
and the Remarks part of MessageDialog:
In : Your app can call showAsync from within the activated handler (the onactivated event or the CoreApplicationView.Activated event ), and paint operations then occur behind the app's splash screen.
So it is not suitable to use FileSavePicker and MessageDialog in the OnShareTargetActivated, it's better to use them in the MainPage. You could navigate to the Main page and activate the current window. After that, passing the parameter to the Main page and in the Loaded event using them. For example:
App.xaml.cs:
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
ShareOperation shareOperation = args.ShareOperation;
if (shareOperation.Data.Contains(StandardDataFormats.StorageItems))
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(MainPage), shareOperation.Data);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
MainPage.cs:
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
var savePicker = new Windows.Storage.Pickers.FileSavePicker();
......
Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();
}