Files
dotnet-maui-workshop/MonkeyFinder/ViewModel/MonkeyDetailsViewModel.cs
2024-04-22 16:48:36 +02:00

44 lines
926 B
C#

namespace MonkeyFinder.ViewModel;
[QueryProperty("Monkey", "Monkey")]
public partial class MonkeyDetailsViewModel : BaseViewModel
{
IMap map;
public MonkeyDetailsViewModel(IMap map)
{
this.map = map;
}
[ObservableProperty]
Monkey monkey;
//[RelayCommand]
//async Task GoBackAsync()
//{
// await Shell.Current.GoToAsync("..");
//}
[RelayCommand]
async Task OpenMapAsync()
{
try
{
await map.OpenAsync(Monkey.Latitude, Monkey.Longitude,
new MapLaunchOptions
{
Name = Monkey.Name,
NavigationMode = NavigationMode.None
});
}
catch (Exception ex)
{
Debug.WriteLine(ex);
await Shell.Current.DisplayAlert("Error!",
$"Unable to open map: {ex.Message}", "OK");
}
}
}