ShowDialog with & without Context

Topics: Getting Started
Nov 13, 2012 at 6:48 AM

Hi,

i'm new to caliburn.micro and trying to learn the basics of this framework.
Now im stuck with ShowDialog.

Why does that work:
var viewmodel = new PackageEditViewModel ();
Package package = new Package ();
var result = _windowManager.ShowDialog (viewmodel);

And this one doesn't:
var viewmodel = new PackageEditViewModel ();
Package package = new Package ();
var result = _windowManager.ShowDialog (viewmodel, package);

Thx for ur help.

Nov 13, 2012 at 8:54 AM

The context is typically used to resolve a view name. It is not meant as a 'Datacontext', so in your case, the Package object will be converted into a string and the resulting view will be a composition of the view name plus the Package type string.

To debug these kind of problems, enable logging providing a proper ILog, then you'll be able to pin point the exact view name the framework is searching for.

Nov 13, 2012 at 10:09 AM

Thx for ur help, i will debug as u mentioned.

But if its not the DataContext, how can i set the Datacontext to a View?

Nov 13, 2012 at 10:12 AM

The datacontext of the view is the viewmodel itself.