Global ResourceDictionary

i follow the example in xamarin forms web:

developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/styles/#Using_Xaml_for_your_App

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

Best Answer

Answers

  • 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="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 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

    by

    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

    x:Class

    i wrote

    x:class

    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.