Link to home
Start Free TrialLog in
Avatar of Dodsworth
Dodsworth

asked on

Initialize Component not declared

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?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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?
Avatar of Dodsworth
Dodsworth

ASKER

<phone:PhoneApplicationPage
    x:Class="PT.MainPage"

---------------------------------------------------------
Namespace PT

    Partial Public Class MainPage
        Inherits PhoneApplicationPage

        ' Constructor
        Public Sub New()
            InitializeComponent()
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmm.. In Windows Phone the x:Class is

<AppName>.<PageName>

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

x:Class="PT.PT.MainPage"

Which I assume equates to

<AppName>.<NameSpaceName>.<PageName>

But the same pattern fails in the App.xaml
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.
I changed the NameSpace name and that made it clearer to see what was going on!