Print Page | Close Window

Cannot find view for Cocktail.DialogBase

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3976
Printed Date: 27-Jun-2026 at 11:13am


Topic: Cannot find view for Cocktail.DialogBase
Posted By: -ook
Subject: Cannot find view for Cocktail.DialogBase
Date Posted: 04-Feb-2013 at 8:40pm

I have followed the advice in the Dialogs and Messageboxes topic on the Ideablade website in order to create a simple Dialog Box with its own viewmodel and view.


After I issue the command: "await _dialogManager.ShowDialogAsync(_namePrompt, DialogButtons.OkCancel);" I get back the error "Cannot find view for Cocktail.DialogHostBase", also in the VS 2012 output window is:

System.Windows.Data Error: 5 : Value produced by BindingExpression is not valid for target property.; Value='<null>' BindingExpression:Path=DisplayName; DataItem='DialogHostBase' (HashCode=43089040); target element is 'Window' (Name=''); target property is 'Title' (type 'String')

The ViewModel and View correctly follow the naming conventions. As a test I can display the control in question embedded on a MainPage - this confirms that Caliburn Micro can fins the view from the viewmodel normally, it just does not work from the dialog manager.

 
Any ideas?



Replies:
Posted By: -ook
Date Posted: 04-Feb-2013 at 8:50pm
Nevermind, found out one has to define a custom Cocktail.DialogHostView before it works.
 
 


Posted By: mgood
Date Posted: 04-Feb-2013 at 10:29pm
I'm a bit confused. Did you subclass Cocktail.DialogHostBase? You only need to do that if you plan on customizing the dialog host. This is not required for a simple dialog. All you have to do is create a ViewModel and View for the content you want to display in the dialog and call _dialogManager.ShowDialogAsync() with it. Cocktail will do the rest. If you look at TempHire you won't find a custom DialogHostView.


Posted By: -ook
Date Posted: 04-Feb-2013 at 11:09pm
I agree with it being confusing. I have not sub classes the DialogHostBase or anything like that, the implementation is as per the example provided http://drc.ideablade.com/devforce-2012/bin/view/Documentation/cocktail-dialog-manager - here .  It appears the Cocktail.DialogHostView cannot be found in the nuget cocktail packages, I downloaded the Cocktail source code and copied Cocktail.DialogHostView.xaml to my project and now it works.




Posted By: mgood
Date Posted: 05-Feb-2013 at 5:57am
Here's the example in form of a WPF application. It works as expected. I'm not sure what's going wrong in your case. Maybe you can compare the sample to what you have. Something must be different. The solution should automatically download the necessary NuGet packages when you build. If you get an error, make sure you allow NuGet to download missing packages in the Package Manager Settings.

http://sdrv.ms/12pLbJU



Posted By: -ook
Date Posted: 19-Feb-2013 at 8:19pm
Turns out I had excluded the Cocktail.dll's using IdeaBlade.Core.Composition.CompositionHost.SearchPatterns.Add. Silly mistake.
Thanks for your help.
 


Posted By: mgood
Date Posted: 19-Feb-2013 at 9:50pm
Thanks for letting me know. Cocktail is supposed to always be included even if you change the SearchPatterns. Sounds like that isn't working anymore. Something to investigate I suppose. 


Posted By: mgood
Date Posted: 21-Feb-2013 at 5:24pm
This will be fixed in the upcoming 2.2.1 release. It will always ensure that Cocktail.dll is included in the catalog.



Print Page | Close Window