Forum Cross Platform with Xamarin


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Global ResourceDictionary

i follow the example in xamarin forms web:

but i cant call InitializeComponent, does anyone have the same error ?

Best Answer


  • adamkempadamkemp USInsider, Developer Group Leader mod

    You need to set up the project so that the .xaml and .xaml.cs files are linked. See this page. Basically, I think the trick is to create a XAML ContentPage and then change it to be an Application subclass instead of a ContentPage subclass.

  • MiltonCondoriMiltonCondori USMember
    edited April 2015

    let me explain what i did.

    my proyect had a App.cs file

    -I eliminated it and create a new XAML class in Visual Studio 2013 (App.xaml and App.xaml.cs).



    • I replaced the ContentPage by Applicatioon

    <Application xmlns="" xmlns:x="" x:Class="MyProyect.App"> <Application.Resources> <ResourceDictionary> . . resources here! . </ResourceDictionary> </Application.Resources> </Application>

    - In App.xaml.cs

    i replaced this line

    public partial class App : ContentPage


    public partial class App : Application

    when i did it its not posible to call InitializeComponent();

    is there something wrong ?

  • AndresCastroAndresCastro USMember

    I'm also getting a error with InitializeComponent when I try and make my application XAML. Maybe it is a bug?

  • MiltonCondoriMiltonCondori USMember

    Hi, i solved this, i had a error that i did not notice, in this tag


    i wrote


    its compiled, build and execute, but didnt allow me call InitializeComponent();

    i just wrote again x:Class and and rebuild to solve the problem, that was my mistake,

    thanks for your answers

    Andres Castro, maybe you can write your code and steps to check it and could help you

  • OliverMaderOliverMader USMember
    edited April 2015

    You just illustrated why one should stick with statically compile-time checked C# code rather than with XAML, besides the obvious performance penalties that come with its runtime interpreted nature.

  • PrawalGuptaPrawalGupta USMember ✭✭

    Hi, I am also not able to resolve InitializeComponent();

  • VanCarlNguyenVanCarlNguyen SEMember ✭✭

    I usually solve InitializeComponent(); by cleaning + rebuilding the project.

Sign In or Register to comment.