Leon, I'm not able to get the code you posted to work, I tried to post my code with and without screenshots of the app but it was deleted, (twice) not sure why.
issues
- I can't get the edit command to fire.
- I can get the edit.png to appear on the line, ( do not really need this , using selecteditem would work for me.)
- not sure how to pass the WorkCheckListItem to the treeinfopage and populate the fields.
The treeinfopage is used to allow me to enter a single line of data and save the data to a file and display the data in a list view.
I thought I could also use treeinfopage to validate and edit the data later if needed. ( by selecting one for the checklistpage record.)
ChecklistPage.xaml
`<ListView x:Name="ChecklistView" ItemsSource="{Binding MyItems}" IsGroupingEnabled="True" GroupShortNameBinding="{Binding Key}" GroupDisplayBinding="{Binding Key}"> `
<ListView.ItemTemplate >
<DataTemplate>
<ViewCell>
checklistPage.xaml.cs
using MapleSugar.PageModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MapleSugar.Pages
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CheckListPage : ContentPage
{
public CheckListPage()
{
InitializeComponent();
BindingContext = new CheckListPageModel();
}
}
}
ChecklistPageModel.cs editDataTapped not called but assume it should be part of editDataAction .
public void EditDataTapped(object sender, System.EventArgs e)
{
WorkTreeLocationItems.Insert(0, new WorkTreeLocationItem
{ WorkSector = Convert.ToInt32(_sector),
WorkTreeNumber = Convert.ToInt32(_treeNumber),
WorkSubTreeNumber = Convert.ToInt32(_subTreeNumber),
WorkTreeSubLetter = _treeSubLetter,
WorkTreeLocation = _treeLocation,
WorkCircumference = Convert.ToDouble(_circumference),
WorkTreeCombineWith = Convert.ToDouble(_treeCombineWith),
WorkComments = _comments,
WorkGridX = Convert.ToDouble(_gridX),
WorkGridY = Convert.ToDouble(_gridY),
WorkLatSec = Convert.ToDouble(_latSec),
WorkLonSec = Convert.ToDouble(_lonSec),
WorkContainer = _container
});
}
public void EditDataAction()
{
WorkCheckListItems = new List<WorkCheckListItem>();
for (int i = 0; i < 10; i++)
{
WorkCheckListItems.Add(new WorkCheckListItem() { Comments = "TEST" + i, Sector = i });
}
EditCommand = new Command((obj) =>
{
var selectedItem = obj as WorkCheckListItem;
//navigate to the detailed page to edit it.
});
}