This project is read-only.

Bfx ShowView()

Feb 1, 2011 at 7:17 PM
I'm implementing a MVVM interface using Bxf and I want to separate the Views from the ViewModels on different assemblies.

From the sample on the MVVM videos, Shell.Instance.ShowView() asks for a Full AssemblyQualifiedName of the view to load. Is there a way to load the View without having to add a circular reference to the Views and ViewModels assemblies?

Thank you
Andres
Coordinator
Feb 1, 2011 at 7:49 PM

The reason the View object uses a string value for the view name is to do what you want.

In my samples I am being lazy. Because I have a reference to the assembly containing the views, I am just getting the assembly qualified type name from the Type object.

But you can provide the assembly qualified type name as a string, in which case you don't need a reference to the assembly containing the views. Like this:

string viewTypeName = "MyNamespace.MyViewClassName,MyAssembly";

The assembly containing the views must be deployed to the application directory at runtime, because the .NET type loader will need to find the assembly. But you don't need a reference for this, you just need to ensure the deployment occurs.

It is also possible to implement your own "view loader" class. That type name string value is only interpreted as an assembly qualified type name by default. If you provide your own view loader, you can interpret that string in any way you choose. For example, you might choose to use the view name string as a key to look up the real type name in a config file, database table, dictionary, or other location.