none
how to solve system.reflection.targetinvocationexception in this MasterDetailPage RRS feed

  • Question

  • Hellow, I am using Xamarin Studio on MacBook Pro and trying to create this master-detail page for one cross-platform application using XAML and CS. it is giving me a runtime error which is saying that i am hitting system.reflection.targetinvocationexception

    Let

    here is my XAML code 

    <?<g class="gr_ gr_179 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" data-gr-id="179" id="179">xml</g> version="1.0" encoding="UTF-8"?>
    <MasterDetailPage  
        xmlns="http://xamarin.com/schemas/2014/forms" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        x:Class="MasterDetail.MainPage"
        IsPresented="true">
        <MasterDetailPage.Master>
            <ContentPage>
        
            <ListView x:Name="listView" SeparatorColor="Red" ItemSelected="Handle_ItemSelected">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                        <ImageCell Text="{Binding Name}" ImageSource="{Binding ImageUrl}">
                  
                        </ImageCell>
                    </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
        
    </ContentPage>
        </MasterDetailPage.Master>
        <MasterDetailPage.Detail>
            <ContentPage />
        </MasterDetailPage.Detail>
    </MasterDetailPage>

    And here is my CS Code 


    using System;
    using System.Collections.Generic;

    using Xamarin.Forms;

    namespace MasterDetail
    {
        public partial class MainPage : MasterDetailPage
        {
             void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
            {
                
                var Show = e.SelectedItem as NavigationMenu;
                Detail = new NavigationPage(new HomePage(Show));
                IsPresented = false;
            }


            public MainPage()
            {
                InitializeComponent();


                listView.ItemsSource = new List<NavigationMenu>{

                    new NavigationMenu { Name = "Home"ImageUrl = "/Users/ironman/Projects/MasterDetail/MasterDetail/Properties/home.png" },
                    new NavigationMenu { Name = "FAQ"ImageUrl = "/Users/ironman/Projects/MasterDetail/MasterDetail/Properties/FAQ.png" },
                    new NavigationMenu { Name = "ContactUS"ImageUrl = "/Users/ironman/Projects/MasterDetail/MasterDetail/Properties/phone.png"}

                };
            }
        }
    }





    Wednesday, January 24, 2018 4:36 PM

All replies

  • Hi Tirth21896,

    Welcome to the MSDN forum.

    This forum is discussing Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    Your issue is related to Xamarin, I suggest you repost a new thread to the following forum for a professional answer.

    https://forums.xamarin.com/  

    Thanks for your understanding.

    Regards,

    Judyzh


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Judy ZhuY Thursday, January 25, 2018 6:12 AM
    Thursday, January 25, 2018 3:22 AM