Initialize Component not declared

Posted on 2014-08-12
Last Modified: 2014-11-12
I have a XAML page with code behind that works fine... Until I wrap the code behind in a Namespace.  Then I get Initialize Component not declared.

I've encountered this before when copying in code from another project, but it's usually fixed by ensuring the XAML x:Class matched the Private Partial Sub name in code behind.

Any ideas?
Question by:Dodsworth
    LVL 96

    Expert Comment

    by:Bob Learned
    That error does mean that it can't find the other part of the partial class.  Can you show just the beginning of the XAML declaration, and the top of the code-behind?
    LVL 1

    Author Comment


    Namespace PT

        Partial Public Class MainPage
            Inherits PhoneApplicationPage

            ' Constructor
            Public Sub New()
    LVL 96

    Accepted Solution

    Gotcha: VB.NET classes and namespaces in XAML

    One difference between XAML in a C# project and VB.NET projects is in specifying the x:Class of your XAML root element
    LVL 1

    Author Comment

    hmm.. In Windows Phone the x:Class is


    and in my example the PT Namespace is the same as the AppName.

    I've managed to get rid of one 'Not Declared' error on the MainPage by specifying


    Which I assume equates to


    But the same pattern fails in the App.xaml
    LVL 96

    Expert Comment

    by:Bob Learned
    I generally don't like for namespaces names to conflict with class or application names.  As a C# developer, I am not used to these oddities with WPF.
    LVL 1

    Author Comment

    I changed the NameSpace name and that made it clearer to see what was going on!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now