View Property not Recognized in Code Behind

Topics: Prism v4 - Silverlight 4
Apr 25, 2011 at 6:32 PM

I wanted to refactor my module project and for starter I just changed the xap name from ModuleA.xap to Mynamespace.Mymodule.xap. I also changed entry in ModuleCatalog.xml to
<Modularity:ModuleInfo Ref=" Mynamespace.Mymodule.xap" InitializationMode="WhenAvailable" ModuleName="ModuleA">
Module name stayed the same (ModuleA) in ModuleCatalog.xml as well as in ModuleInit, like:

namespace ModuleA {
   [ModuleExport("ModuleA", typeof(ModuleInit))]
   public class ModuleInit : IModule, IModuleInit {

When I tried to run it I noticed that all the named elements in my views, like “group” here:
<TextBlock x:Name="group" TextWrapping="Wrap" FontWeight="Normal"/>
Are not recognized any more in code behind where I get null for reference.

Any explanation for this kind of behavior?


Apr 25, 2011 at 8:27 PM


We've tried to reproduce the behavior you're mentioning, but we were unable to. Aside from the xap filename, have you changed the assembly name of your module?


Guido Leandro Maliandi

Apr 26, 2011 at 7:25 AM

Yes. I changed assembly name too.

Apr 27, 2011 at 2:25 PM
Edited Apr 27, 2011 at 2:26 PM


You should take into account that, if you change the assembly name of your module's project, you need to modify the ModuleType in the modules catalog. For example, if you had the following entry:


ModuleType="ModuleB.ModuleB, ModuleB, Version=, Culture=neutral, PublicKeyToken=null"


and you changed the assembly name to ModuleBChanged, you should update it to this:

ModuleType="ModuleBChanged.ModuleB, ModuleB, Version=, Culture=neutral, PublicKeyToken=null"

Therefore, you could try specifying the Module Type taking into account the aforementioned consideration.

I hope you find this helpful.

Guido Leandro Maliandi