1
votes

I am using the Caliburn Micro Window Manager to display a dialog. I would like to remove the maximize and minimize buttons from the dialog.

If I look at the Windows Manager source (under WPF) I can see a third parameter that lets me pass settings to the dialog. My problem is that I can't pass a third parameter - I get an error. This can be replicated in the hello window manager example project.

Any ideas?

Somehow I seem to be referencing an IWindowManager that only allows 2 parameters to ShowDialog.

This is what I want to do but causes an error:

var loginViewModel = new LoginViewModel();

WindowManager windowManager = new WindowManager();

Dictionary<string, object> settings = new Dictionary<string, object>();

// add settings here to pass to dialog

windowManager.ShowDialog(loginViewModel, null, settings);

This is IWindowManager interface that shows 3 parameters:

public interface IWindowManager
{
    /// <summary>
    /// Shows a modal dialog for the specified model.
    /// </summary>
    /// <param name="rootModel">The root model.</param>
    /// <param name="context">The context.</param>
    /// <param name="settings">The optional dialog settings.</param>
    /// <returns>The dialog result.</returns>
    bool? ShowDialog(object rootModel, object context = null, IDictionary<string, object> settings = null);

    /// <summary>
    /// Shows a non-modal window for the specified model.
    /// </summary>
    /// <param name="rootModel">The root model.</param>
    /// <param name="context">The context.</param>
    /// <param name="settings">The optional window settings.</param>
    void ShowWindow(object rootModel, object context = null, IDictionary<string, object> settings = null);

    /// <summary>
    /// Shows a popup at the current mouse position.
    /// </summary>
    /// <param name="rootModel">The root model.</param>
    /// <param name="context">The view context.</param>
    /// <param name="settings">The optional popup settings.</param>
    void ShowPopup(object rootModel, object context = null, IDictionary<string, object> settings = null);
}
3
Please show some code, for those of us not intimately familiar with Caliburn Micro's implementation details. :)Dan J
Have added code example.Steve Chadbourne

3 Answers

4
votes
dynamic settings = new ExpandoObject();
            settings.WindowStyle = WindowStyle.ToolWindow;
            settings.ShowInTaskbar = false;
            settings.Title = "Test";

windowManager.ShowDialog(loginViewModel, "Modeless", settings);
1
votes

I don't recall any recent version of Caliburn.Micro that used IWindowManager.ShowDialog with three parameters. Are you maybe referring to this link from the Codeplex site? It appears to be a user request that Rob rejected.

As you probably know, ShowDialog() will cause the IWindowManager to instantiate a view it finds (by naming convention) and attach it to whatever viewmodel you provide it (e.g. LoginViewModel is attached to a "found" view called LoginView).

I'm guessing that LoginView is a UserControl for you, but you can have this view be a regular Window and then set the WindowStyle property (in XAML) to use one of the options that does not have the maximize button. This MSDN article shows the various enumeration options. WindowStyle.ToolWindow is the only one that includes the close button and not the min/max buttons, but because it changes the appearance of the close button, you may prefer WindowStyle.None and just define your own window chrome and buttons.

<Window x:Class="MyNamespace.LoginView"
        ...
        WindowStyle="ToolWindow">
    ...
</Window>
1
votes

Instead of having your View as Usercontrol make it a Window and set its ResizeMode="NoResize"

<Window x:Class="Company.Project.Views.MyView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ResizeMode="NoResize">

Now you will only have red "X" close button and no maximize/minimize buttons.