2012-05-04 44 views
0

我正在使用Caliburn Micro的MVVM, 所以我能夠OpenViews,但無法移動它們。如何在ShellView中移動Caliburn Micro子視圖?

我已經設置了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} 
    }); 
} 

請幫忙。

回答

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(); 
}