initial commit
This commit is contained in:
57
Gallery.Share/ViewModels/ItemDetailViewModel.cs
Normal file
57
Gallery.Share/ViewModels/ItemDetailViewModel.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.Models;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.ViewModels
|
||||
{
|
||||
[QueryProperty(nameof(ItemId), nameof(ItemId))]
|
||||
public class ItemDetailViewModel : BaseViewModel
|
||||
{
|
||||
private string itemId;
|
||||
private string text;
|
||||
private string description;
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => text;
|
||||
set => SetProperty(ref text, value);
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get => description;
|
||||
set => SetProperty(ref description, value);
|
||||
}
|
||||
|
||||
public string ItemId
|
||||
{
|
||||
get
|
||||
{
|
||||
return itemId;
|
||||
}
|
||||
set
|
||||
{
|
||||
itemId = value;
|
||||
LoadItemId(value);
|
||||
}
|
||||
}
|
||||
|
||||
public async void LoadItemId(string itemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var item = await DataStore.GetItemAsync(itemId);
|
||||
Id = item.Id;
|
||||
Text = item.Text;
|
||||
Description = item.Description;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Debug.WriteLine("Failed to Load Item");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user