0

我将 Caliburn Micro 用于 MVVM,所以我可以打开视图,但不能移动它们。

我已经设置WindowStyle=None,这是我的代码。

private void OpenView(object ViewModel)
{
    windowManager.ShowWindow(ViewModel,
    settings: new Dictionary<string, object>
    {
        {"Background",Brushes.Transparent},
        { "WindowStyle", WindowStyle.None},
        { "ShowInTaskbar", false},  
        {"AllowsTransparency",true}
    });
}

请帮忙。

4

1 回答 1

0

从 Caliburn Micro 的 WindowManager.cs 中删除您的 CreateWindow 并添加此代码。

protected virtual Window CreateWindow(object rootModel, bool isDialog, object context, IDictionary<string, object> settings) {
    var view = EnsureWindow(rootModel, ViewLocator.LocateForModel(rootModel, null, context), isDialog);
    ViewModelBinder.Bind(rootModel, view, context);

    var haveDisplayName = rootModel as IHaveDisplayName;
    if (haveDisplayName != null && !ConventionManager.HasBinding(view, Window.TitleProperty)) {
        var binding = new Binding("DisplayName") { Mode = BindingMode.TwoWay };
        view.SetBinding(Window.TitleProperty, binding);
    }


    view.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(Window_MouseDown);
    ApplySettings(view, settings);

    new WindowConductor(rootModel, view);

    return view;
}

void Window_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    var view = sender as Window;
    view.DragMove();
}
于 2012-05-11T06:29:16.580 回答