내가이
private void MainWindow_PreviewMouseMove(object sender, MouseEventArgs e) {
if (e.LeftButton == MouseButtonState.Pressed) {
this.DragMove();
foreach (var window in App.Current.Windows.OfType<Window>()) {
window.Move(); // move it
}
}
}
같은 일을하고자하는 "기본"창을 이동할 때 내가이 솔루션을 사용하려면 두 개 이상의 끈끈한 창을 이동하려면 이동할 수있는 방법 http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf/
하지만 난 그것을 어떻게 이동할 수 있습니다 WPF 의 창
스냅/스티커/자기 윈도우 스냅 하시나요?
편집은 구스타보 카 발칸 티의 응답 후, 나는 몇 가지 생각을했다. 여기 내 질문에 대한 대략적인 해결책이 있습니다.
using System.Windows;
using System.Windows.Data;
namespace DragMoveForms
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1() {
this.InitializeComponent();
}
public Window1(Window mainWindow)
: this() {
var b = new Binding("Left");
b.Converter = new MoveLeftValueConverter();
b.ConverterParameter = mainWindow;
b.Mode = BindingMode.TwoWay;
b.Source = mainWindow;
BindingOperations.SetBinding(this, LeftProperty, b);
b = new Binding("Top");
b.Converter = new MoveTopValueConverter();
b.ConverterParameter = mainWindow;
b.Mode = BindingMode.TwoWay;
b.Source = mainWindow;
BindingOperations.SetBinding(this, TopProperty, b);
}
}
}
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace DragMoveForms
{
public class MoveLeftValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
// ok, this is simple, it only demonstrates what happens
if (value is double && parameter is Window) {
var left = (double)value;
var window = (Window)parameter;
// here i must check on which side the window sticks on
return left + window.ActualWidth;
}
return 0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return DependencyProperty.UnsetValue;
}
}
}
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace DragMoveForms
{
public class MoveTopValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
// ok, this is simple, it only demonstrates what happens
if (value is double && parameter is Window) {
var top = (double)value;
var window = (Window)parameter;
// here i must check on which side the window sticks on
return top;
}
return 0;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
return DependencyProperty.UnsetValue;
}
}
}
훨씬 나아졌습니다! – SvenG