New Posts New Posts RSS Feed: Caliburn Micro and multiple view-models with the same view caused a problem
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Caliburn Micro and multiple view-models with the same view caused a problem

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: Caliburn Micro and multiple view-models with the same view caused a problem
    Posted: 11-Dec-2012 at 11:57am
Great! Yes, the NameTransformer is the proper way to handle custom view resolution.
Back to Top
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post Posted: 11-Dec-2012 at 11:50am
Actually, my code (or the code copied from that link) tries to find a View considering the view specified in UseView attribute or using the name of the ViewModel removing the word Model.

So, after your reply, I decided to check what was going on and had my problem solved removing that ViewLocatorConfigurator class and UseViewAttribute.

Now, I have a better solution (or the correct one). I added a rule in ViewLocator.NameTransformer with a regex that solved my problem (use the same view for multiple view-models) and I have no problems on Cocktail :) 

Thank you Marcel.

Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 10-Dec-2012 at 12:45pm
I don't have much to go on here. Cocktail.DialogHostBase is a ViewModel and not a View. It is created through MEF by the DialogManager whenever you try to show a popup and it should already be created by the time CM tries to find the corresponding View, which would invoke your custom locator logic. It sounds like your code is accidentily trying to create the ViewModel instead of the View. Maybe you can post the stack trace so I have a better idea where exactly this is happening.
Back to Top
cefernan View Drop Down
Groupie
Groupie


Joined: 13-Jul-2012
Posts: 70
Post Options Post Options   Quote cefernan Quote  Post ReplyReply Direct Link To This Post Posted: 10-Dec-2012 at 11:26am
Hello,

I have implemented a different behavior as described in:
http://www.emidee.net/index.php/2010/09/30/caliburn-micro-how-to-use-the-same-view-for-multiple-view-models/

So, after that, my application shows always the same message in any exception:
Cannot create Cocktail.DialogHostBase

I guess the problem is that my code (ViewLocatorConfigurator) is not able to find the correct view to show the message.

Do you have any suggestion to solve that?

PS: My application is based on TempHire architecture.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down