I've got an application that has structure like that:
Main View with menu --press button--> List View --select item from listview--> Modal window.
Each modal window contains button, that launches youtube video:
await Launcher.Default.OpenAsync(new Uri($"vnd.youtube://{link}"));
Same behaviour if i try to open document:
await Browser.Default.OpenAsync(new Uri(link.ToString())
Even though youtube video opens, when i go back to application it is back to Main View. How can i force app to stay in the same view when Launcher is executed?
Note: It did work as intended on Xamarin.Forms...
EDIT: Button/Image code in xaml:
<Image Grid.Row="9" Grid.Column="1" HeightRequest="50" WidthRequest="50" HorizontalOptions="Start" IsVisible="{Binding HasDocumentLink}" Source="pdf_icon" >
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="Document_Tapped" CommandParameter="{Binding BoardGame.TutorialLink}" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
And full method in view model:
private void Document_Tapped(object sender, EventArgs e)
{
var link = ((TappedEventArgs)e).Parameter;
Browser.Default.OpenAsync(new Uri(link.ToString()), BrowserLaunchMode.SystemPreferred);
}
EDIT2: On request, also ItemTemplate for opening modal window:
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BindingContext.TapCommand, Source={x:Reference BoardGamesView}}" CommandParameter="{Binding .}" NumberOfTapsRequired="1"/>
</Grid.GestureRecognizers>
Viewmodel:
private void OnItemTapped(BoardGame boardGame)
{
App.Current.MainPage.Navigation.PushModalAsync(new BoardGamePage(boardGame), false);
}