This is a migrated thread and some comments may be shown as answers.

Custom Commands

2 Answers 56 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 03 Feb 2019, 05:46 PM

Hi everybody. I'm using this controller's commands option. I'm following the guides and it works, however, whenever I try to navigate to another page, I get this error: "PushAsync is not supported globally on iOS, please use a NavigationPage.".

I tried moving my code from the ViewModel to the Content page where I invoque the view model. The tree lodes the data just fine, but now it won't recognize the tap action.

async void OnItemTap(object p)
        {
            var context = (TreeViewItemCommandContext)p;
            var item = context.Item as ItemsArbol;
            await Application.Current.MainPage.DisplayAlert("", "You clicked on: " + (context.Item as ItemsArbol).Nombre, "OK");

            if (!Equals(item.Tipo, "0"))
            {
                idOrgMod = item.Id;
                idOrgModPadre = item.Padre;
                Application.Current.Properties["idOrgMod"] = idOrgMod;
                Application.Current.Properties["idOrgModPadre"] = idOrgModPadre;
                await Application.Current.SavePropertiesAsync();
                await Navigation.PushAsync(new OrganizacionesDetalle());

            }
        }

How can I make the content view recognize the ItemTap action? In case this isn't possible, how can I make the viewmodel display the new page when I tap the tree's item?

 

Thanks in advance for your help.

 

 

2 Answers, 1 is accepted

Sort by
0
Dennis
Top achievements
Rank 1
answered on 04 Feb 2019, 05:34 PM
I got it to work now, setting my main page as a navigation page.
0
Didi
Telerik team
answered on 05 Feb 2019, 08:12 AM
Hi Dennis,

I am glad to hear that you have solved the issue with the navigation. 

Also for more details regarding the complex navigation when the MVVM pattern is used in the apps, you could take a look at the following article in Xamatin.Forms documentation: Enterprise App Navigation.

Let me know if you have any additional questions or concerns.

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeView
Asked by
Dennis
Top achievements
Rank 1
Answers by
Dennis
Top achievements
Rank 1
Didi
Telerik team
Share this question
or