Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can i move sticky / snapping wpf windows
    text
    copied!<p>i want move two or more sticky windows when i move a "main" window</p> <p>i want do something like this</p> <pre><code>private void MainWindow_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { this.DragMove(); foreach (var window in App.Current.Windows.OfType&lt;Window&gt;()) { window.Move(); // move it } } } </code></pre> <p>i want use this solution for snapping the windows</p> <p>Snapping / Sticky / Magnetic Windows for WPF <a href="http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf/" rel="nofollow">http://programminghacks.net/2009/10/19/download-snapping-sticky-magnetic-windows-for-wpf/</a></p> <p>but how can i move it?</p> <p><strong>EDIT</strong></p> <p>After the reply from Gustavo Cavalcanti, i made ​​a few thoughts. Here is a rough solution to my question.</p> <pre><code>using System.Windows; using System.Windows.Data; namespace DragMoveForms { /// &lt;summary&gt; /// Interaction logic for Window1.xaml /// &lt;/summary&gt; 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 &amp;&amp; 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 &amp;&amp; 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; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload