Infragistics(R) NetAdvantage(R) : WPF 2012.1
Handle Moving Events
E-mail your feedback on this topic.
Shared XAML > Interactions > xamDialogWindow > Using xamDialogWindow > Handle Moving Events

Glossary Item Box

There are two events associated with moving the dialog window. These events have the suffix “ing” or “ed” appended to them, reflecting the order in which they occur. The moving events allow you to perform some custom logic before or after the dialog window is moved.

Moving – The moment right before the dialog window is moved, the Moving event fires. This event can be cancelled if certain conditions are not met. 

Moved – This event fires after the dialog window has moved.

In XAML:

<Grid x:Name="LayoutRoot" Background="White">
   <ig:XamDialogWindow Content="Dialog Window" 
      x:Name="DialogWindow" Width="200" Height="200" 
      Moved="DialogWindow_Moved" Moving="DialogWindow_Moving"/>
</Grid>


In Visual Basic:

Imports Infragistics.Controls.Interactions
…
AddHandler DialogWindow.Moved, AddressOf DialogWindow_Moved
AddHandler DialogWindow.Moving, AddressOf DialogWindow_Moving
…
Private Sub DialogWindow_Moving(ByVal sender As System.Object, ByVal e As MovingEventArgs)
   'Don't allow the dialog window to move more than 200 pixels 
   If (e.Left > 200) Then
      e.Cancel = True
      System.Diagnostics.Debug.WriteLine("Moving Cancelled")
      Return
   End If
   System.Diagnostics.Debug.WriteLine("Dialog Window Moving Successfully")
End Sub

Private Sub DialogWindow_Moved(ByVal sender As System.Object, ByVal e As MovedEventArgs)
   System.Diagnostics.Debug.WriteLine("Dialog Window has moved successfully. 
                             New left coordinate is " + e.Left.ToString() + 
                             ", new top coordinate is " + e.Top.ToString())
End Sub


In C#:

using Infragistics.Controls.Interactions;
…
DialogWindow.Moved += new EventHandler<MovedEventArgs>(DialogWindow_Moved);
DialogWindow.Moving += new EventHandler<MovingEventArgs>(DialogWindow_Moving);
…
void DialogWindow_Moving(object sender, MovingEventArgs e)
{
    //Don't allow the dialog window to move more than 200 pixels 
   if (e.Left > 200)
   {
      e.Cancel = true;
      System.Diagnostics.Debug.WriteLine("Moving Cancelled");
      return;
   }
   System.Diagnostics.Debug.WriteLine("Dialog Window Moving Successfully");
}

void DialogWindow_Moved(object sender, MovedEventArgs e)
{
   System.Diagnostics.Debug.WriteLine("Dialog Window has moved successfully. 
                          New Left coordinate is "+e.Left+
                          ", new top coordinate is "+e.Top);
}


Related Topics

Custom Cursors

Customize Modal Dialog Window Background

Customize the Window Header Icon

Handle Window State Changing Events

Keyboard Settings

Modal and Modeless Dialog Windows

Position Minimized Dialog Window

Set the Dialog Window's Height and Width When Minimized

Start Up Position of xamDialogWindow

The xamDialogWindow Control's Behavior

Window Header Controls