Hello @v12doom ,
In the task view page, it will display the task details and the subtasks. The issue is that I can't figure out how to display the associated subtasks for the specific task id.
I check the source code your provided, there is a ListView
to display the detailed task on Subtask
page, an Entry
and three buttons to add/delete/cancel task(There is also a ToolbarItem
to add subtask). You want to select one item on MainPage
, then display the task list (or click the ToolbarItem to add a task), then select a task to navigate to Subtask
, right? If so, you can refer to the following code:
On Subtask
Page:
async void OnItemAdded(object sender, EventArgs e)
{
var item = (task)BindingContext;
await Navigation.PushAsync(new subtaskadd()
{
BindingContext = new subtask()
{
taskId = item.Id// ass a new subtask, pass the taskId
}
}) ;
}
async void OnClicklist(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem != null)
{
await Navigation.PushAsync(new subtaskadd()
{
BindingContext = e.SelectedItem as subtask
});
}
}
On database.cs
public async Task<int> SaveItemAsync2(subtask item)
{
List<subtask> items = await Database.Table<subtask>().Where(i => i.Id == item.Id).ToListAsync();// check if the subtask exists in the table
if (items.Count != 0)
{// if it is in the table, you can update
subtask st = items[0];
st.taskId = item.taskId;
st.sub = item.sub;
return await Database.UpdateAsync(st);
}
else
{
return await Database.InsertAsync(item);
}
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.