Add project files.
This commit is contained in:
43
MonkeyFinder/ViewModel/MonkeyDetailsViewModel.cs
Normal file
43
MonkeyFinder/ViewModel/MonkeyDetailsViewModel.cs
Normal file
@ -0,0 +1,43 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user