Subfolders and Namespaces in VB.Net differ in behaviour with C#

Aug 15, 2014 at 4:39 PM
Edited Aug 15, 2014 at 4:40 PM
The examples run fine in C#, but after I had translated into VB.Net, I struggle with the namespaces. Just putting Pages in the Views folder seems to be insufficient, the pages cannot be found.
Overriding the GetPageType gives other issues (see the issue I have openend for that).

Introducing namespaces like in the C# example, gives trouble with the InitializeComponent statement of every single Page.

So there is appearently a difference (and why is that so??) between the namespace behaviour in VB and C#.

How do I correct this and get it up and running in VB.Net?

Best regards,

Aug 20, 2014 at 6:47 AM
Edited Aug 20, 2014 at 6:48 AM
After spending more than a few hours on this subject, I think I have it sorted out.
Appearently there is a (big) difference in the way C# and VB treat subfolders and namespaces. Why do I find that nowhere in any documentation?
I think it would be very helpful for all those VB programmers out there to point this out more explicitly (and explain how to get over it) in the documentation.

In general what I found out is this:
When putting views in a subfolder like the framework expects, they need to be explicitly made part of the namespace Views as well. That is not done automatically as it seems to be done in C#. Moreover, in the XAML that reference to the namespace must be made in the class header.


MainPage.xaml.vb has to be within the namespace Views like so:

Namespace Views
''' <summary>
''' A basic page that provides characteristics common to most applications.
''' </summary>
Public NotInheritable Class MainPage
    Inherits VisualStateAwarePage
    Public Sub New()
    End Sub
End Class
End Namespace

And in the XAML header the namespace has to be added like so:


I hope this will help some other VB programmers to be able to adopt Prism.